“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 mI5J]hk
Y6&v&dA;
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 ii_kgqT^
}LCm_av
以下是用不同语言写成的Hello World程序的几个例子: <T?-A}0uO
Ada yuy\T(7BN
with Ada.Text_Io; use Ada.Text_Io; \I:27:iAL
procedure Hello is P
JATRJ1.
begin _7\`xU
Put_Line ("Hello, world!"); Y<|JhqOXK
end Hello; cE:s\hG
Ufl\
uq3'H
M 9-Q
汇编语言 :A
zll s
aXQS0>G%(
x86 CPU,DOS,TASM .CnZMw{'
MODEL SMALL ;-8.~Sm
IDEAL dVYY:1PS
STACK 100H ,@c1X:
*1Bq>h:
DATASEG tVO}{[U}
HW DB 'Hello, world!$' z
&Xl
$1"gFg
CODESEG L /:^;j`c
MOV AX, @data \#(1IC`as
MOV DS, AX SGSyO0O
MOV DX, OFFSET HW YTFU#F
MOV AH, 09H 26g]_Igq
INT 21H (_|*&au J
MOV AX, 4C00H haBmwq(f
INT 21H ,|d9lK`" P
END _Iminet
iMJt8sd
l99Lxgx=
x86 CPU,GNU/Linux,NASM >zqaV@T
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). 4/|x^Ky>G
;Enter this into "hello.asm" then type: BK%.wi
;"nasm -f elf hello.asm" `@
YV
;"ld hello.o -o hello" sBB[u'h!
;"./hello" ?tY+P`S
u>)h
section .data ;data section declaration ']TWWwj$
msg db 'Hello World!',0AH
P4q5#r
len equ $-msg ;string length u+Ix''Fn#%
dkz%
Y]
section .text ;code section declaration uUg;v/:
global _start ;entry point (start of execution) tu<<pR>
_start: mov edx,len ;string length BW7AjtxQ&
mov ecx,msg ;string start {iX#
mov ebx,1 ;file handle: stdout ".
tW5O>
mov eax,4 ;sys_write |dLr #+'az
int 80h ;kernel system call wYf\!]}'
. 2$J-<O
mov ebx,0 ;return value 5PO_qr=Hx
mov eax,1 ;sys_exit JyZuj>`
6
int 80h ;kernel system call o *J*}y
Vt(Wy
q@~g.AMCB
x86 CPU,Windows,MASM32 F<