“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 OSBR2Z;=
|AYii-g
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 cYSn
S;~eI8gQ"
以下是用不同语言写成的Hello World程序的几个例子: 7`|'Om?'
Ada |Z:yd}d
with Ada.Text_Io; use Ada.Text_Io; )OI}IWDl
procedure Hello is YVIE v
begin DyC*nE;
Put_Line ("Hello, world!"); 1Lb)S@Q`*R
end Hello; <Lb LMV
&~:EmLgv
de:@/-|
汇编语言 f"Sp.'@
0#V"
x86 CPU,DOS,TASM 9Yt|Wj
MODEL SMALL '2lV(>"
IDEAL yYz{*hq
STACK 100H |`T7}U
-.D?Z8e
DATASEG v=k+MvX
HW DB 'Hello, world!$' i}m'#b
d{fd5jv;
CODESEG lR?y
tIY
MOV AX, @data !tq]kKJ3:
MOV DS, AX &y?
|$p\;/
MOV DX, OFFSET HW :8yebOs
MOV AH, 09H IdmP!(u
INT 21H ![z2]L+TB
MOV AX, 4C00H @76}d
INT 21H x6cG'3&T
END mP)bOAU
zyPb\/
Wl| i$L)7
x86 CPU,GNU/Linux,NASM $ }/tlA&e
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). 7Z>vQ f B
;Enter this into "hello.asm" then type: >CvhTrPI
;"nasm -f elf hello.asm" byM%D$R
;"ld hello.o -o hello" P^te
;"./hello" f ,e]jw@
vHi%UaD-y
section .data ;data section declaration ]
(e ,J
msg db 'Hello World!',0AH utck{]P
len equ $-msg ;string length tA1?8`bQ
bB<S4@jF8z
section .text ;code section declaration 6,q0F*q
global _start ;entry point (start of execution) \&F4Wl>`
_start: mov edx,len ;string length +$C9@CZM9
mov ecx,msg ;string start %R GZu\p
mov ebx,1 ;file handle: stdout o*K7(yUL4
mov eax,4 ;sys_write 0>Y3xNb
int 80h ;kernel system call |k}<Zz1UM
8g-u
mov ebx,0 ;return value %n$f#Ml_r
mov eax,1 ;sys_exit [{Wo:c9Qq1
int 80h ;kernel system call 6FDj :~
"](Q2
wR_mJMk_
x86 CPU,Windows,MASM32 <zXG}JuL@T
.386 /
&Z8g4vc
.model flat,stdcall "L.k
m
option casemap:none NfDS6i.Fqp
;Include 文件定义 Zj[m
include windows.inc .>W [
include user32.inc R+!U.:-yz
includelib user32.lib 4b<|jVl\
include kernel32.inc ;!f='QuA
includelib kernel32.lib |uy@v6
;数据段 n
n F
.data 6%V:Z
szCaption db 'A MessageBox!',0 0(i3RPIj\
szText db 'Hello,world!',0 _i>_S n1"
;代码段 `,4yGgD!4
.code q{h,}[U=
start: 0er|QC
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK p@pb[Bx~[
invoke ExitProcess,NULL +pYgh8w@
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> {XU!p: x
end start l2;$qNAo
b@J "b(
((gI OTV
AWK T.cTL.}
BEGIN { print "Hello, world!" } 4D&