“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 giSG 6'WA
qy42Y/8'
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 @E"+qPp.3
y_7XYT!w
以下是用不同语言写成的Hello World程序的几个例子: d4/`:?w
Ada %)6:eIS
with Ada.Text_Io; use Ada.Text_Io; eRl?9
procedure Hello is r"u(!~R
begin xo)?XFM2
Put_Line ("Hello, world!"); YCB 3
end Hello; UTK.tg
53u.pc
m[xf./@f{
汇编语言 lc$@Jjg9
/m{?o
x86 CPU,DOS,TASM '/yx_RK2?
MODEL SMALL ^?^|Y?f2P?
IDEAL ;5oH6{7_Z
STACK 100H LnRi+n[@7
4}_w4@(
DATASEG X $9D0;L
HW DB 'Hello, world!$' |Qt`p@W
fssL'DD
CODESEG YI),q.3X~
MOV AX, @data Kt* za
MOV DS, AX b1>$sPJ+
MOV DX, OFFSET HW Jm J,~_
MOV AH, 09H "w|k\1D
INT 21H Jn:GA@[I
MOV AX, 4C00H MTITIecw=
INT 21H Ff#N|L'9_
END 5W]N]^v
aXK%m
Y'a(J 7
x86 CPU,GNU/Linux,NASM 1'U%7#;E
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). _8b>r1$
;Enter this into "hello.asm" then type: IO)Ft
;"nasm -f elf hello.asm" +$m skj0s
;"ld hello.o -o hello" gmAKW4(
;"./hello" @
H`QLm
R?9Plzt5
section .data ;data section declaration 8H`l"
msg db 'Hello World!',0AH ~z1KD)^
len equ $-msg ;string length (b2^d
D>x'3WYR
section .text ;code section declaration S~(VcC$K
global _start ;entry point (start of execution) $Q$d\Yvi
_start: mov edx,len ;string length !RUo:b+
mov ecx,msg ;string start \utH*;J|x
mov ebx,1 ;file handle: stdout -K'84 bZ
mov eax,4 ;sys_write nPIR1Z
int 80h ;kernel system call !/(}meZj
<sFf'W_3{
mov ebx,0 ;return value ieF 0<'iF
mov eax,1 ;sys_exit j83Y'VJJC
int 80h ;kernel system call QEHZ=Yg%3
\w_[tPz}
z`:^e1vG
x86 CPU,Windows,MASM32 np>!lF:
.386 ds[Z=_Ll
.model flat,stdcall J&Qy