“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 ?>B?*IK!
o-@01_j
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 O.+J%],
ZPH_s^
以下是用不同语言写成的Hello World程序的几个例子: 2p&$bft
Ada <YW)8J
with Ada.Text_Io; use Ada.Text_Io; Z{B
e
procedure Hello is W4o8]&A
begin r.eK;
Put_Line ("Hello, world!"); \x-2qlZ
end Hello; RH FRN&RU$
H0s*Lb
cA Nt7
汇编语言 cTq@"v di
or*{P=m+R
x86 CPU,DOS,TASM gHPJiiCv
MODEL SMALL Pg8.RvmQ
IDEAL 4;AF\De
STACK 100H 2jyWkAP'
f0H.$UAL
DATASEG VNTbjn]
HW DB 'Hello, world!$' v7"VH90`!
@*eY~
CODESEG PgA<pfEHE
MOV AX, @data ` Tap0V
MOV DS, AX tBGLEeL/.
MOV DX, OFFSET HW &za
}THm
MOV AH, 09H <J<"`xKL
INT 21H K80f_iT5
MOV AX, 4C00H `-{l$Hn9|~
INT 21H *,z/q6
END !CU-5bpu
DU\ytD`u
KyNu8s k
x86 CPU,GNU/Linux,NASM K[icVT2v~
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). Q/SO%E`E
;Enter this into "hello.asm" then type: )Dz]Pv]H'
;"nasm -f elf hello.asm" VZt%cq
;"ld hello.o -o hello" Wo
"s ;Z
;"./hello" e8<}{N0,n
HF*0
section .data ;data section declaration [P+kQBLpL
msg db 'Hello World!',0AH C>Hdp_Lm
len equ $-msg ;string length *>a=ku:?
W On<;'}M&
section .text ;code section declaration bN/8 ~!
global _start ;entry point (start of execution) R>0[w$
_start: mov edx,len ;string length W^8
mov ecx,msg ;string start d` ttWWPw
mov ebx,1 ;file handle: stdout h,$CJdDY]
mov eax,4 ;sys_write 5a/A?9?,
int 80h ;kernel system call HDV-qYD|O~
R5ra*!|L)
mov ebx,0 ;return value 7<)H?;~;
mov eax,1 ;sys_exit )xy>:2!#Y
int 80h ;kernel system call 2H%lN`
\(pwHNSafk
>
'=QBW
x86 CPU,Windows,MASM32 GM2}]9
.386 ![%wM Pp
.model flat,stdcall c[ZrQJ
option casemap:none {Phq39g
;Include 文件定义 2VY7?1Ab(@
include windows.inc :4zu.
include user32.inc v's1&%sM
includelib user32.lib D;P=\i>9-
include kernel32.inc /''=V.-N
includelib kernel32.lib f!kZyD7
;数据段 uZL]mwkj]
.data 4m<]qw
szCaption db 'A MessageBox!',0 Bug.>ln1
szText db 'Hello,world!',0 G{[w+ObX
;代码段 k( Sda>-
.code xmnBG4,f
start: <<01@Q <