“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 }6__E;h#J
FGo)]U
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 I=E\=UTG,5
b3=XWzK5
以下是用不同语言写成的Hello World程序的几个例子: '
b,zE[Q
Ada h5; +5B}D
with Ada.Text_Io; use Ada.Text_Io; H M\}C.u
procedure Hello is rsK
b9G
begin w (,x{Bg\
Put_Line ("Hello, world!"); OH5#.${O
end Hello; ]`@<I'?,X
cc3+Wx_
Nm0|U.<
汇编语言 y|#Fu
_lOyT$DN
x86 CPU,DOS,TASM 7YU}-gi
MODEL SMALL N1]P3
IDEAL `b5pa `\4
STACK 100H [4}U*\/>C
4=;`\-7!
DATASEG QJH~YV\%
HW DB 'Hello, world!$' 6)3pnhG9
'p,54<e
CODESEG U$IB_a2
MOV AX, @data .ffb*gZ4
MOV DS, AX
["Jt2
MOV DX, OFFSET HW k?Iq 6
MOV AH, 09H ~,84E [VV
INT 21H R?kyJ4S
MOV AX, 4C00H s !HOrhV
INT 21H oSs~*mf
END /.@"wAw:
j1$s^ -9
O ;B[ZMV
x86 CPU,GNU/Linux,NASM Dn.%+im-u
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). @w[HXb
;Enter this into "hello.asm" then type: "[\TL#/
;"nasm -f elf hello.asm" K!SFS
;"ld hello.o -o hello" {c AGOx wd
;"./hello"
m3 Rss~l
MvlqxJ$
section .data ;data section declaration Q2xzux~T
msg db 'Hello World!',0AH s\
YHT.O?
len equ $-msg ;string length 69{q*qCW
'WJ3q|o/
section .text ;code section declaration j |ZhGerp
global _start ;entry point (start of execution) A>J,Bi
_start: mov edx,len ;string length a.s5>:Ct
mov ecx,msg ;string start $2pkh%
mov ebx,1 ;file handle: stdout QetyuhS~
mov eax,4 ;sys_write r1[Jo|4vo
int 80h ;kernel system call GUqBnRA8j
7F wot&