“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 s=}~Q&8
l+'`BBh*]
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 AzW%+ LUD
/!o1l\i=5
以下是用不同语言写成的Hello World程序的几个例子: DD)mN)
&T
Ada IFkvv1S`
with Ada.Text_Io; use Ada.Text_Io; se"um5N-
procedure Hello is (h%|;9tF
begin nEuct4BcL}
Put_Line ("Hello, world!"); MgSp.<!
end Hello; xQ_:]\EZ
S@;&U1@h
.2{ 6h
汇编语言 Y#.6d
}$&);7(w
x86 CPU,DOS,TASM [cY?!Qd0
MODEL SMALL )OS>9
kFH
IDEAL .Lp Nm'=R
STACK 100H 4E,hcu
re2Fv:4{
DATASEG |^\Hv5
HW DB 'Hello, world!$' ``/y=k/au
hu`Lv
CODESEG CD$u=E
]
MOV AX, @data 'XG:1Bpm
MOV DS, AX h7)VJY
MOV DX, OFFSET HW ~&vA_/M
MOV AH, 09H `mQP{od?"?
INT 21H cG<Q`(5~
MOV AX, 4C00H H{&a)!Ms
INT 21H 4/ 0/#G#j
END +YkmLD
lsN/$M|}
S]Sp Z8
x86 CPU,GNU/Linux,NASM {: Am9B
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). #xD&z^o
;Enter this into "hello.asm" then type: o$^O<z L
;"nasm -f elf hello.asm" )jp{*?^\
;"ld hello.o -o hello" h,Y{t?Of
;"./hello" :$+D
2*(
c
g3Cl[s
section .data ;data section declaration 3m?@7 F
msg db 'Hello World!',0AH uVoF<={
len equ $-msg ;string length i,C0o
?nj"Ptzs
section .text ;code section declaration +6i7,U
global _start ;entry point (start of execution) MLEIx()
_start: mov edx,len ;string length JuKk"tr~RB
mov ecx,msg ;string start #3AYz82w
mov ebx,1 ;file handle: stdout w+URCj
mov eax,4 ;sys_write )UxQf37
int 80h ;kernel system call ski1f
L5i#Kh_
mov ebx,0 ;return value !-
Cs?
mov eax,1 ;sys_exit 8T!fGzHx
int 80h ;kernel system call $4#=#aKW.
<yPq;#z(!
- I1cAt
x86 CPU,Windows,MASM32 5e~ j
.386 Ac*B[ywA3
.model flat,stdcall /gMa" 5?,
option casemap:none OtrXYiKB
;Include 文件定义 @+QYWh'
include windows.inc 9y
d-&yDG
include user32.inc
<Hq6]\<
includelib user32.lib .If"'hMY
include kernel32.inc )Gu0i7iN
includelib kernel32.lib 4O5n6~24
;数据段 \#IJ=+z
.data d&$.jk8 2
szCaption db 'A MessageBox!',0 Q6e'0EIKC
szText db 'Hello,world!',0 Xs.$2
;代码段 &m