“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 yN9/'c~
t\ ym4`"
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 [&51m^
Hi#hf"V
以下是用不同语言写成的Hello World程序的几个例子: Q/I/>6M7UZ
Ada T< D&%)
with Ada.Text_Io; use Ada.Text_Io; nwf(`=TC
procedure Hello is F8nR.|
begin ^tI
,eZ
Put_Line ("Hello, world!"); /C}u,dBf
end Hello; Ch>r.OfP
vkp_v1F%+
X3@Uih}|
汇编语言 ';Y0qitGB
)1N~-VuT
x86 CPU,DOS,TASM !ap}+_IA7^
MODEL SMALL OQ&l/|{O0?
IDEAL XkDIP4v%
STACK 100H ZwM(H[iqL
~m3Q^ue
DATASEG 8MU+i%hd
HW DB 'Hello, world!$' mb,\ wZ
)\Am:?RH;
CODESEG %g: 6QS|
MOV AX, @data yw\Q>~$n[=
MOV DS, AX QWcQtM
MOV DX, OFFSET HW kntYj}F(
MOV AH, 09H A`71L V%
INT 21H t^
Ge "
MOV AX, 4C00H |0OY>5
INT 21H $t0o*i{
END Ym% XCl
5If.[j{
42M_ %l_
x86 CPU,GNU/Linux,NASM -Gy=1W`09
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). s5h}MXIXw
;Enter this into "hello.asm" then type: =U'!<w<-
;"nasm -f elf hello.asm" 8wV`mdKN
;"ld hello.o -o hello" S#kYPe
;"./hello" |P@N}P@
7>"dc+Fg
section .data ;data section declaration Wn2'uZ5If
msg db 'Hello World!',0AH U$|q]N
len equ $-msg ;string length ^hNl6)hR
0 30LT$&!
section .text ;code section declaration \#4mPk_"
global _start ;entry point (start of execution) D6-R>"}
_start: mov edx,len ;string length S4\a"WYg
mov ecx,msg ;string start tq}MzKI*
mov ebx,1 ;file handle: stdout @Bds0t
mov eax,4 ;sys_write p]0`rf!|
int 80h ;kernel system call C#-HWoSi
]~2iducB,
mov ebx,0 ;return value ^"<x4e9+j
mov eax,1 ;sys_exit eAmI~oku
int 80h ;kernel system call da<