“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 YZBh}l6t
WD[eoi
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 >0IZ%Wiz
;hX( /T
以下是用不同语言写成的Hello World程序的几个例子: 6gg8h>b
Ada $E\|\g
with Ada.Text_Io; use Ada.Text_Io; d!y*z
procedure Hello is <=q}
Nd\
begin 8vY-bm,e
Put_Line ("Hello, world!"); >d 2Fa4u3
end Hello; 5~JT*Ny
`Z?wj@H1`
;<AcW.jx
汇编语言 EiW|+@1
/fr> Fd
x86 CPU,DOS,TASM u]J@65~'b
MODEL SMALL *x"80UXL
IDEAL ;Ba%aaHl
STACK 100H $"^K~5Q
86r5!@WN
DATASEG KQdIG9O+6
HW DB 'Hello, world!$' <$(B [T
^/2I)y]W0
CODESEG k"(]V
MOV AX, @data 0M_oFx
MOV DS, AX x<NPp&GE
MOV DX, OFFSET HW BX@Iq
MOV AH, 09H Tu#< {'1$
INT 21H g7*)|FOb
MOV AX, 4C00H yw3"jdcl
INT 21H a:h<M^n049
END |"3<\$[
7;"0:eX
u/zBz*zh
x86 CPU,GNU/Linux,NASM $cCC
1=dW
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). V#t_gS
;Enter this into "hello.asm" then type: X
W)TI
;"nasm -f elf hello.asm" "ZuuSi
;"ld hello.o -o hello" &XP(D5lf`B
;"./hello" Bh>L"'.2
d8j1L/e
section .data ;data section declaration P#,u9EIJ
msg db 'Hello World!',0AH QHEtG2
len equ $-msg ;string length `Lf'/q
n|SV)92o1
section .text ;code section declaration }h5i Tc
global _start ;entry point (start of execution) )+E[M!34
_start: mov edx,len ;string length 1j<(?MT-
mov ecx,msg ;string start z ^gJy,T
mov ebx,1 ;file handle: stdout K}VCFV
mov eax,4 ;sys_write CLb6XnkcA\
int 80h ;kernel system call ~GaGDS\V
AZtS4]4G)
mov ebx,0 ;return value a|aVc'j
mov eax,1 ;sys_exit tZrc4$D-
int 80h ;kernel system call kNEEu!G
Lsmcj{1d
^PksXfk
x86 CPU,Windows,MASM32 J3K=z
.386 &|>+LP@8
.model flat,stdcall Y::0v@&(
option casemap:none lfGyK4:
;Include 文件定义 ]n22+]D
include windows.inc _"DS?`z6
include user32.inc a^|DD#5
includelib user32.lib mo0\t#jA
include kernel32.inc [m
t.2 .
includelib kernel32.lib 5gszAvOO
;数据段 H"Pb)t
.data XH:*J+$O
szCaption db 'A MessageBox!',0 z*y!Ml1
szText db 'Hello,world!',0 `&$8/_`
;代码段 ${+u-Wfau
.code c8qr-x1HG
start: 8sG3<$Z^
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK $Gn.G_"v
invoke ExitProcess,NULL pMc6p0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> yC,/R371k
end start WeI+|V$
|D3u"Y!:^
Q M,!-~t
AWK N0U/u'J!g
BEGIN { print "Hello, world!" } #Ondhy%h[
)Nv1_en<!
o_b[ *
BASIC cPGlT"
传统版BASIC(例如GWBASIC): |m19fg3u
<P9fNBGa
10 PRINT "Hello, world!" Tt[zSlIMx
20 END BG{f)2F\
TQ
Vk;&A
或在提示符输入: 2EY"[xK|
?HZp@&
?"Hello, world!":END .=_p6_G
eE;tiX/
现代版BASIC(例如Quick BASIC): -wlj;U
0ju1>.p
Print "Hello, world!" SGd]o"VF
ZSMed(//b
以下的语句在Quick BASIC中同样有效: ]-PzN'5\'
I0=_=aZO(
? "Hello,world!"
gwZ<$6
&4'<