“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 LEtGrA/%@b
^[}W} j>
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 tWzB Qx
oq,nfUA
以下是用不同语言写成的Hello World程序的几个例子: ni2 [K`
Ada dMsS OP0E
with Ada.Text_Io; use Ada.Text_Io; fJ5mKN
procedure Hello is .57Fh)Y
begin "q= ss:(
Put_Line ("Hello, world!"); >@cBDS<6R
end Hello; 8%YyxoCH
M=ag\1S&ZF
"$J5cco
汇编语言 CMbID1M3
|.yS~XFJS
x86 CPU,DOS,TASM _[(EsIqc(F
MODEL SMALL G4'Ee5(o
IDEAL lfCr`[!E
STACK 100H ;/wH/!b
'm|T"Ym~
DATASEG bo<.pK$
HW DB 'Hello, world!$' IgwHC0W
!s/qqq:g
CODESEG D4y!l~_,%M
MOV AX, @data +HWFoK
MOV DS, AX FNOsw\Bo
MOV DX, OFFSET HW jck(cc=R
MOV AH, 09H -~xQ@ +./
INT 21H ia;osqW
MOV AX, 4C00H na9YlJ\
INT 21H \<xo`2b
END 0g=vMLi
3WwCo.q;m
us1$
x86 CPU,GNU/Linux,NASM 2-ksr}:
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). |Rx+2`6Dp
;Enter this into "hello.asm" then type: g{sp<w0
;"nasm -f elf hello.asm" 4Hb"yp$
;"ld hello.o -o hello" {`
bX*]
;"./hello" >7cj.%
qc)+T_m
section .data ;data section declaration tl* v(ZW
msg db 'Hello World!',0AH T|h!06
len equ $-msg ;string length )=#Js<&3:
AX6:*aZB
section .text ;code section declaration ecH7")
global _start ;entry point (start of execution) Kf(Px%G6K
_start: mov edx,len ;string length E>*Wu<<
mov ecx,msg ;string start 1R*;U8?
mov ebx,1 ;file handle: stdout R=,
pv'
mov eax,4 ;sys_write xW9R-J\W
int 80h ;kernel system call sGNHA(;
vRW;{,d
mov ebx,0 ;return value QQ{*j7i)
mov eax,1 ;sys_exit NYg&