“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 u/y`M]17
U`:#+8h-}
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 qJ"dkT*
^67P(h
以下是用不同语言写成的Hello World程序的几个例子: $NG}YOP)@
Ada `z5j
with Ada.Text_Io; use Ada.Text_Io; ;-^WUf|
procedure Hello is %'4dgk
begin jDgiH}
Put_Line ("Hello, world!"); na
$z\C\
end Hello; vT%rg r
)@1_Dm@0b
y
@Y@"y
汇编语言 0gO2^m)W
!S%XIq}FX
x86 CPU,DOS,TASM _4zlEo-.gU
MODEL SMALL og.dYs7W4
IDEAL Zf]d'oW{/
STACK 100H A+Y>1-=JO
I g-VSQ
DATASEG Ao`9 fI#q
HW DB 'Hello, world!$' ^;W,:y&
CL9p/PJ%e
CODESEG evg i\"
MOV AX, @data dWD9YIYf
MOV DS, AX }Ss#0Gee
MOV DX, OFFSET HW >\}2("bv
MOV AH, 09H #5G!lbH
INT 21H I.y|AQB
MOV AX, 4C00H e#kPf 'gL
INT 21H nsw.\(#
END 79:x>i=
JZu7Fb]L9
8-juzL}
x86 CPU,GNU/Linux,NASM b4ORDU
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). r^ #.yUz
;Enter this into "hello.asm" then type: 0
"pm7
;"nasm -f elf hello.asm" b0LQ$XM>8
;"ld hello.o -o hello" 0\o0(eHCQz
;"./hello" @WBy:gV"
UTin0k
section .data ;data section declaration [_-CO}>
msg db 'Hello World!',0AH vj?9X5A_
len equ $-msg ;string length HEjV7g0E
D\j1`
section .text ;code section declaration -U%wLkf|
global _start ;entry point (start of execution) G:u[Lk#6K
_start: mov edx,len ;string length /d'^XYOC
mov ecx,msg ;string start RG:ct{i
mov ebx,1 ;file handle: stdout h5Qxa$Oq
mov eax,4 ;sys_write uZmfvMr3
int 80h ;kernel system call lP9a*>=a
:Nc~rOC_
mov ebx,0 ;return value ",&}vfD4M
mov eax,1 ;sys_exit ':o.vQdJ
int 80h ;kernel system call #0G9{./C
1vl~[
qYsu3y)*N
x86 CPU,Windows,MASM32 Q(Vc/
.386 ]jY->NsA]
.model flat,stdcall M9bb,`X>Q
option casemap:none l4R:_Z<
;Include 文件定义 6],5X^*Y
include windows.inc v8 6ls[lzu
include user32.inc DNki
xE*
includelib user32.lib 7zR7v
include kernel32.inc ' 'UiQ
includelib kernel32.lib tBrd+}e2*
;数据段 js8uvZ i
.data 68 - I2@&
szCaption db 'A MessageBox!',0 _e ~EQ[,
szText db 'Hello,world!',0 <0R?#^XBZB
;代码段 u^ngD64
.code wF@qBDxg
start: d+2I+O03
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK iKp4@6an
invoke ExitProcess,NULL Pb]s+1
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 0p
Lb<&