“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 2_i/ F)W
<sdC#j
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 anLSD/'4W
W
&wqN
以下是用不同语言写成的Hello World程序的几个例子: BPRhGG|9j
Ada <X]'":
with Ada.Text_Io; use Ada.Text_Io; l0AVyA4RFV
procedure Hello is 8K(3{\J[V
begin F?"#1je
Put_Line ("Hello, world!"); hH Kd+QpI
end Hello; ?+6w8j%\
)Pr*\<Cld
Gp*U2LB
汇编语言 G.Z4h/1<
66RqjP '2
x86 CPU,DOS,TASM NlLgXn!
MODEL SMALL fd Vye|%
IDEAL eYSVAj
STACK 100H VL6_in(
Wp5w}8g
DATASEG >v1E;-ZA
HW DB 'Hello, world!$' "^?|=sQ
4q%hn3\
CODESEG H# P)n
R
M
MOV AX, @data Y ;qA@|
MOV DS, AX *hugQh]a
MOV DX, OFFSET HW kl4u]MyL#
MOV AH, 09H R^t
)~\d
INT 21H #L,>)Xk jS
MOV AX, 4C00H ?r< F/$/
INT 21H x[%z \
END `8 Q3=^)3
wO\,?SI4
lawjGI
x86 CPU,GNU/Linux,NASM bBwMx{iNNz
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). >|Xy'ZR
;Enter this into "hello.asm" then type: u+
wKs`
;"nasm -f elf hello.asm" z>n<+tso
;"ld hello.o -o hello" ]{2Eo
;"./hello" &RSUB;ymL
s]=bg+v?j
section .data ;data section declaration Ndb_|
msg db 'Hello World!',0AH ,gdf7&r
len equ $-msg ;string length D I`
M
Z.!tp
section .text ;code section declaration c UJUZ@ol
global _start ;entry point (start of execution) drv"I[}{A
_start: mov edx,len ;string length IiX`l6L~W
mov ecx,msg ;string start u+U '|6)E
mov ebx,1 ;file handle: stdout B Q)1)8r
mov eax,4 ;sys_write +i %,+3#6
int 80h ;kernel system call \W^+aNbv=8
+a@:?=hc
mov ebx,0 ;return value I $5*Puy#
mov eax,1 ;sys_exit CBj&8#8Z
int 80h ;kernel system call T[$! ^WT
Er 4P
,F4_ps?(
x86 CPU,Windows,MASM32 M@R_t(&=
.386 ]yR0"<W^xO
.model flat,stdcall .bwKG`F
option casemap:none xKol
;Include 文件定义 >icL,n"]
include windows.inc ow,4'f!d
include user32.inc OJ2O?Te8
includelib user32.lib T~*L[*F0
include kernel32.inc ]GSs{'UhB
includelib kernel32.lib >Ei-Spy>Xl
;数据段 U}r^M(
s!
.data 6f$h1$$)^
szCaption db 'A MessageBox!',0 4sj:%%UE
szText db 'Hello,world!',0 f,e7;u z%
;代码段 q;XO1Se
.code c5 jd
q[0
start: jl!rCOLt4
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK !!WSGZUR
invoke ExitProcess,NULL N*dO'ol
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> {;iG}j K
end start 2N,<~L`FX'
3,7SGt
r
3I rmDT
AWK \P3[_kbf1
BEGIN { print "Hello, world!" } <