“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 '*5i)^
_P0T)-X\(
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 s5CXwM6cx
C-Q28lD}f
以下是用不同语言写成的Hello World程序的几个例子: U>]$a71
Ada &;^YBW :I
with Ada.Text_Io; use Ada.Text_Io; }=<
procedure Hello is YC++&Nk
begin Z/k:~%|E
Put_Line ("Hello, world!"); kW;+|qs^
end Hello; &,zq%;-f
kD=WO4}
,{M^-3C
汇编语言 ZrPbl"`7
KN<S}3MN
x86 CPU,DOS,TASM /N =b\-]
MODEL SMALL R3x3]]D
IDEAL qTdh eX/
STACK 100H W>) M5t4i
K^1o DP
DATASEG 2bJQTk _S
HW DB 'Hello, world!$' tScPa,(
''yB5#^w(
CODESEG r_
I5.gK
MOV AX, @data r[|Xy>Zj
MOV DS, AX OLyf8&AU@
MOV DX, OFFSET HW gG0!C))8
MOV AH, 09H /rWd=~[MO
INT 21H 3{'Ne}5%I
MOV AX, 4C00H 8aK)#tNWN
INT 21H [tlI!~Z
END '(U-(wTC'/
Q# ~Q=T'<
_K]_
@Ivh
x86 CPU,GNU/Linux,NASM |2O]R s
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). .+PI}[g
;Enter this into "hello.asm" then type: u+Y\6~=+
;"nasm -f elf hello.asm" %|auAq&w
;"ld hello.o -o hello" tr<Nm6!
;"./hello" Hx"ob_^'7
Q-_N2W?
section .data ;data section declaration CAfGH!l!
msg db 'Hello World!',0AH ((H^2KJn
len equ $-msg ;string length $ `ov4W
zd2)M@
section .text ;code section declaration a=J^
global _start ;entry point (start of execution) my(2;IJ#{
_start: mov edx,len ;string length n6wV.?8
mov ecx,msg ;string start \y97W&AN
mov ebx,1 ;file handle: stdout gH12[Us'`
mov eax,4 ;sys_write /sx@$cvW
int 80h ;kernel system call JZ)RGSG i
)#?"Gjf~
mov ebx,0 ;return value |n2qVR,
mov eax,1 ;sys_exit ) pzy
int 80h ;kernel system call Fq0i`~L~
dMh:ulIY>
3eb%OEMYk
x86 CPU,Windows,MASM32 J?V? R
.386 ^yW L,$
.model flat,stdcall r(:5kC8K
option casemap:none wo4;n9@I
;Include 文件定义 A
9( x
include windows.inc 3x`|
include user32.inc * aN
includelib user32.lib ,k24w7K%d
include kernel32.inc V3&RJ k=b
includelib kernel32.lib &Y!-%{e
;数据段 IdzxS
.data U>YAdrx2a
szCaption db 'A MessageBox!',0 &TUWW