“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 &&Uc%vIN
Y`U[Y Hx
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 T>!Y-e.q
/qKO9M5A
以下是用不同语言写成的Hello World程序的几个例子: y3,'1^lA
Ada q2pq~LI
with Ada.Text_Io; use Ada.Text_Io; :c_>(~
procedure Hello is RRasX;zK
begin mPmg6Qj(W
Put_Line ("Hello, world!"); $GMva}@G`
end Hello; (59u<F
u>K(m))5W3
]ZbZ]
汇编语言 iE}Lw&x
}Qqi013E L
x86 CPU,DOS,TASM &>YdX$8x
MODEL SMALL ;PA^.RB
IDEAL q[wVC
h
STACK 100H ri]"a?Rm
ac2G;}B|
DATASEG _wY<8 F*
HW DB 'Hello, world!$' >k)zd-
fx"~WeVcO
CODESEG kwM1f=!-
MOV AX, @data W/\M9
MOV DS, AX Jn+k$'6%#
MOV DX, OFFSET HW ){sn!5=
MOV AH, 09H t=6[FK
INT 21H KkCA*GS
MOV AX, 4C00H ag7(nn0!
INT 21H #guq/g$
END ZJod=^T
4)DI0b"
/Tc
I
x86 CPU,GNU/Linux,NASM |E(`9
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). l_1y#B-k5
;Enter this into "hello.asm" then type: ]E:P-xTwaI
;"nasm -f elf hello.asm" K,$Ro@!
;"ld hello.o -o hello" <*vWcCS1
;"./hello" 3[a&|!Yw
[8h~:.d`
section .data ;data section declaration fl4z'8P"(
msg db 'Hello World!',0AH ij|+MX
len equ $-msg ;string length ;
*@lH%u
f\zu7,GU
section .text ;code section declaration Vt[Kr
global _start ;entry point (start of execution) $ lC*q
_start: mov edx,len ;string length H;=JqD8`
mov ecx,msg ;string start gE}+`w/X
mov ebx,1 ;file handle: stdout `nvm>u~[Hq
mov eax,4 ;sys_write &y~~Z [.F,
int 80h ;kernel system call &l