“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 SGXXv
T4]/w|?G
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 p^3]Q
3%bCv_6B
以下是用不同语言写成的Hello World程序的几个例子: B:\\aOEj
Ada ZgP=maQk
with Ada.Text_Io; use Ada.Text_Io; 9.{u2a\
procedure Hello is "_eHK#)
begin TD'Rv Tpl
Put_Line ("Hello, world!"); aHNR0L3$}{
end Hello; (0 /,R
R9A8)dDz
|L}zB,
汇编语言 -*~= 4m<
12`q9Io"
x86 CPU,DOS,TASM c@wSv2o$
MODEL SMALL {_&'tXL
IDEAL #` Q3Z}C
STACK 100H 48hu=,)81*
x$Y44v'>
DATASEG UbNA|`H
HW DB 'Hello, world!$' @<=x fs
]VtVw^ ir
CODESEG hiq7e*Nsb
MOV AX, @data D99g}
MOV DS, AX
o=}}hE\H
MOV DX, OFFSET HW jd8`D6|Z
MOV AH, 09H F0:|uC4
INT 21H :)o 4fOJ8
MOV AX, 4C00H 6_]-&&Nr
INT 21H 'w3BSaJi
END v%v(-, _q
+Z> Y//
kW#,o 9f\
x86 CPU,GNU/Linux,NASM R[KF${X4
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). `B6*wE-|
;Enter this into "hello.asm" then type: _&V%idz!0
;"nasm -f elf hello.asm" %J(y2 }
;"ld hello.o -o hello" (3cJ8o>&
;"./hello" R=
,jqW<
%LyZaU_sB
section .data ;data section declaration mApn[)?tv
msg db 'Hello World!',0AH g_X-.3=2K
len equ $-msg ;string length gZA[Sq
NwAvxN<R(f
section .text ;code section declaration EQe !&;
global _start ;entry point (start of execution) T8<pb^#
_start: mov edx,len ;string length DJ_[{WAV
mov ecx,msg ;string start 4'3do>!
mov ebx,1 ;file handle: stdout F6
mc<