“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 ?2b9N ~
.oo>NS
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 %@FTg$
Nm=W?i
以下是用不同语言写成的Hello World程序的几个例子: ?5 d3k%
Ada 5 ERycC y
with Ada.Text_Io; use Ada.Text_Io; C zvi':
procedure Hello is }mC-SC)oSi
begin AHR[i%3W
Put_Line ("Hello, world!"); `p%&c%*A
end Hello; #yVY!+A
izi=`;=D^
zKk2>.
汇编语言 ABp/uJI)
5<ycF_
x86 CPU,DOS,TASM Kq';[ Yc
MODEL SMALL s0"1W"7vh
IDEAL !(Y23w*
STACK 100H f"5vpU^5*
[nlW}1)46
DATASEG Tce2]"^;
HW DB 'Hello, world!$' `D%bZ%25c
lU.@! rGbw
CODESEG U{o0Posg
MOV AX, @data o3l_&?^
MOV DS, AX Xu:Sh<:R
MOV DX, OFFSET HW OPwj*b:-m
MOV AH, 09H m>6,{g)
INT 21H pemb2HQ'4j
MOV AX, 4C00H xAD: Z"
INT 21H nV%1/e"5
END BS;_l"?
e? fFh,a
~V"D|U;i +
x86 CPU,GNU/Linux,NASM pRj1b^F5y
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). D[)g-_3f6<
;Enter this into "hello.asm" then type: Dw^d!%Ala
;"nasm -f elf hello.asm" ]|[oL6"
;"ld hello.o -o hello" o84!$2P+w
;"./hello" ;p#)z/zZ
>LwZ"IEV
section .data ;data section declaration T)]5k3{
msg db 'Hello World!',0AH Pz1pEyuL
len equ $-msg ;string length MDS;qZx=
Jx@3zl
section .text ;code section declaration .4~n|d>z
global _start ;entry point (start of execution) \0m[Ch}~ey
_start: mov edx,len ;string length 70L{u+wIy
mov ecx,msg ;string start </|IgN$w`
mov ebx,1 ;file handle: stdout *O|Z[>
mov eax,4 ;sys_write Llk4 =p
int 80h ;kernel system call C_Y^<
^~2GhveBV
mov ebx,0 ;return value nmVL%66K
mov eax,1 ;sys_exit { CkxUec
int 80h ;kernel system call <w.W[ak
?*a:f"vQ
@U(D&_H,K
x86 CPU,Windows,MASM32 C-$S]6
.386 1
{dhGX
.model flat,stdcall n=n!Hn
option casemap:none _.OajE\T
;Include 文件定义 ^'~+ w3M@
include windows.inc 9Ay*'
include user32.inc _rK}~y=0
includelib user32.lib b&Qj`j4]ZM
include kernel32.inc a="Z]JGk
includelib kernel32.lib !~cTe!T
;数据段 C9U~lcIS
.data *S_eYKSl
szCaption db 'A MessageBox!',0 eqQA st#~
szText db 'Hello,world!',0 m#mM2Guxe
;代码段 !h{qO&ZH=
.code `6b!W0$
-
start: }r6SV%]:
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK i!<