“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 EEL,^3KR
-%4,@
x`
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 {7pli{`
D3K8F@d
以下是用不同语言写成的Hello World程序的几个例子: <\S:'g"(
Ada
W!(LF7_!
with Ada.Text_Io; use Ada.Text_Io; "^iYLQOC
procedure Hello is %N_%JK\{@
begin ^dxTm1Z
Put_Line ("Hello, world!"); ]}X
end Hello; Vf1^4t
P1f[%1
-D~%|).'
汇编语言 |vzl. ^"-
K~EmD9
x86 CPU,DOS,TASM v(%*b,^
MODEL SMALL -H-~;EzU
IDEAL r,2g^K)6
STACK 100H 0Y5_PTWb+Y
S0W||#Pr
DATASEG BfiD9ka-z
HW DB 'Hello, world!$' ~7Ux@Sx;
yEQs:v6L~
CODESEG /2VJX@h
MOV AX, @data 9-m=*|p
MOV DS, AX Qe(:|q_
MOV DX, OFFSET HW ku
M$UYTTX
MOV AH, 09H ,MIV=*
INT 21H 7 Fsay+a
MOV AX, 4C00H @9|hMo
INT 21H PeEj&4k
END U,1-A=Og{o
={Qi0Pvt
|
VDV<g5h
x86 CPU,GNU/Linux,NASM IO:G1;[/2L
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). FML(4BY,
;Enter this into "hello.asm" then type: w@fi{H(R
;"nasm -f elf hello.asm" ( &x['IR
;"ld hello.o -o hello" bi;1s'Y<D
;"./hello" g<
.qUBPKX
vY`s'%WV
section .data ;data section declaration Ny)X+2Ae
msg db 'Hello World!',0AH C+&l<
fM&
len equ $-msg ;string length Eu04e N
jb!i$/%w
section .text ;code section declaration ZqO^f*F>h
global _start ;entry point (start of execution) 18:%~>.!
_start: mov edx,len ;string length 0+b1vhQ
mov ecx,msg ;string start #C@FYOf*
mov ebx,1 ;file handle: stdout K\c#ig
mov eax,4 ;sys_write BTrn0
int 80h ;kernel system call ;i+#fQO7Q
8DaL,bi*.
mov ebx,0 ;return value uWE^hz"
mov eax,1 ;sys_exit lks!w/yCF
int 80h ;kernel system call SMK_6?MZ
e\75:oQ
;i:d+!3XwC
x86 CPU,Windows,MASM32 RViuJ;
.386 }*"p?L^p{
.model flat,stdcall Kx JqbLUC
option casemap:none IIx#2r
;Include 文件定义 uY'HT|@:{
include windows.inc 7. ;3e@s
include user32.inc ` sU/& P
includelib user32.lib ,$&&-p I]
include kernel32.inc @Do= k
includelib kernel32.lib ;sFF+^~L
;数据段 [j'X;tVX{
.data 3sZ\0P}
szCaption db 'A MessageBox!',0 ,s;UfF
szText db 'Hello,world!',0 .#pU=v#/[
;代码段 G,w(d@
.code Thit
start: VY\&8n}e(
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK SasJic2M
invoke ExitProcess,NULL R{T$[$6S
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> du^J2m{f
end start 8)I^ t81
(dSL7nel;L
(Ep\Z 6*
AWK !%0 *z
BEGIN { print "Hello, world!" } Ma"]PoP
IPo?:1x]s
;4~hB
BASIC W5MTD]J
传统版BASIC(例如GWBASIC): Q]>.b%s[
1&Z