“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 [:!D.@h|
^KK6 d
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 J0vCi}L
~ST7@-D0
以下是用不同语言写成的Hello World程序的几个例子: ~~_!&
Ada DxLN{g]B
with Ada.Text_Io; use Ada.Text_Io; p kR+H|
procedure Hello is C r~!N|(
begin ,!RbFME&H
Put_Line ("Hello, world!"); Iq-+X3i
end Hello; f;;(Q-.
3K57xJzK
'y?(s+
汇编语言 'v"{frh
G=lket6
x86 CPU,DOS,TASM _lE0_X|d
MODEL SMALL $0MP*TFWa
IDEAL dm&vLQVS
STACK 100H 7]~65@%R-&
5`B!1
DATASEG qdFYf/y
HW DB 'Hello, world!$' )NwIEk>Tf
|hprk-R*OH
CODESEG ?4U|6|1
MOV AX, @data '}D$"2I*
MOV DS, AX ^=nJ,-(h_
MOV DX, OFFSET HW rU/V~;#%
MOV AH, 09H kR0d]"dr
INT 21H l 6;}nG
MOV AX, 4C00H iJza zQ
INT 21H cb k|LQ.O
END il \q{Y
o
fr1/9E;
OI9V'W$
x86 CPU,GNU/Linux,NASM q+/c+u?=^
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). W7a aL
;Enter this into "hello.asm" then type: 1{sf Dw[s
;"nasm -f elf hello.asm" vElVw.
P
;"ld hello.o -o hello" zd+_
BPT
;"./hello" ;MqH)M
cj:!uhZp7
section .data ;data section declaration Ed%8| M3
msg db 'Hello World!',0AH J0e~s
len equ $-msg ;string length RfMrGC^?
(P-Bmu!s
section .text ;code section declaration {:VUu?5-t;
global _start ;entry point (start of execution) szY=N7\S*
_start: mov edx,len ;string length k{op ,n#
mov ecx,msg ;string start Q]Fm4
mov ebx,1 ;file handle: stdout 'Lw4jq
mov eax,4 ;sys_write z@nJ-*'U8
int 80h ;kernel system call |uT&`0T'e`
a_UVb'z
mov ebx,0 ;return value k:Iz>3O3]
mov eax,1 ;sys_exit S0_#h)
int 80h ;kernel system call BTwLx-p9t
m8q3Pp
9}{i8
<