“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 l)[\TD
U s86.@|
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 n .ZLR=P4
PUV)w\!&is
以下是用不同语言写成的Hello World程序的几个例子: "^F#oo%L
Ada NZ djS9
with Ada.Text_Io; use Ada.Text_Io; Y ( x_bJ
procedure Hello is KtchKpv
begin 1uZ[Ewl]
Put_Line ("Hello, world!"); CL.JalR`b
end Hello; OSQZ5:g|
DZ92;m
k{;"Aj:iL
汇编语言 bXF>{%(}E
M$~3`n*^
x86 CPU,DOS,TASM @X4Ur+d
MODEL SMALL T6h-E^Z
IDEAL 26PUO$&b.
STACK 100H |t+M/C0y/
fuSfBtLPR#
DATASEG ZQXv-"
HW DB 'Hello, world!$' GmP)"@O](;
S-}MS"
CODESEG u.sF/T=6f
MOV AX, @data N-`Vb0;N
MOV DS, AX dU1w)Y
MOV DX, OFFSET HW 5LdVcXf
MOV AH, 09H BZejqDr*
INT 21H w`=_|4wFw
MOV AX, 4C00H PtCO';9[
INT 21H uPKq<hBI
END 1^XuH('
(MhC83|?
Z:DEET!c'k
x86 CPU,GNU/Linux,NASM 4
AZ~<e\
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). 9pUvw_9MY
;Enter this into "hello.asm" then type: aSdh5?
;"nasm -f elf hello.asm" qzS 9ls>>
;"ld hello.o -o hello" <k?ofE1o
;"./hello" 7K.&zn
E
.^5N~.
section .data ;data section declaration Mx{VN
P
msg db 'Hello World!',0AH E}AOtY5a
len equ $-msg ;string length 9<u^.w
g?`g+:nug
section .text ;code section declaration !$Aijd s5
global _start ;entry point (start of execution) BC*vG=a
_start: mov edx,len ;string length [p[nK=&r
mov ecx,msg ;string start H,,-;tN?
mov ebx,1 ;file handle: stdout e9e%8hL
mov eax,4 ;sys_write
bj23S&
int 80h ;kernel system call ?&;d#z*4
9rXbv4{
mov ebx,0 ;return value :*bv(~FW
mov eax,1 ;sys_exit +v4P9V|s
int 80h ;kernel system call L#sw@UCK
$$ %4,\{l
h4rIt3`
x86 CPU,Windows,MASM32 {Hncm
.386 ?_mcg8A@@*
.model flat,stdcall :$k':0 n
option casemap:none )006\W|t9
;Include 文件定义 Vp8t8X1`
include windows.inc }L
Q9db1
include user32.inc I)#=#eI*:
includelib user32.lib MuNM)pyxp
include kernel32.inc L9tjHC]
includelib kernel32.lib z'@j9vT
;数据段 dFY]~_P472
.data AA][}lU:5
szCaption db 'A MessageBox!',0 C!Cg.^;
szText db 'Hello,world!',0 <$\vL
;代码段 \#4??@+Xf
.code )|;*[S4
start: &qw7BuF
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK W: Rs 0O
invoke ExitProcess,NULL C${{&$&