“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 G.Z4h/1<
/;P* ?
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 Y\#+-E
,]CZ(q9-
以下是用不同语言写成的Hello World程序的几个例子: oqM(?3 yv
Ada PeCU V6
with Ada.Text_Io; use Ada.Text_Io; WGy3SV )
procedure Hello is lM0`yh
begin Z?@1X`@
Put_Line ("Hello, world!"); m]}%Ag^x
end Hello; c j-_
{ zGM[A
&U<t*"
汇编语言 6k14xPj
{|cuu"j26
x86 CPU,DOS,TASM xOfZ9@VU
MODEL SMALL IC5[:UZ5]
IDEAL 9hoTxWpmy
STACK 100H x.gRTR`7(
M? 7CBqZ
DATASEG kl4u]MyL#
HW DB 'Hello, world!$' f~bZTf
<hG] f%
CODESEG AH?T}t2
MOV AX, @data NR98I7
MOV DS, AX a3i;r M2
MOV DX, OFFSET HW gie.K1@|
MOV AH, 09H VE_% /Fs,
INT 21H
LHy-y%?i
MOV AX, 4C00H X0G
Mly
INT 21H x !)[l;
END "v%|&@
/%O+]#$`0
^uG^XY&ItC
x86 CPU,GNU/Linux,NASM Z?XgY\(a(Q
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). k2]Q~
;Enter this into "hello.asm" then type: 3RYg-$NK[
;"nasm -f elf hello.asm" (WoKrd.!
;"ld hello.o -o hello" funHznRR
;"./hello" ]{2Eo
gW0{s[}T
section .data ;data section declaration z
xe6M~+
msg db 'Hello World!',0AH q ERdQ~M,
len equ $-msg ;string length QY$Z,#V)
vsFRWpq
section .text ;code section declaration {3V%
global _start ;entry point (start of execution) ;0R|#9oX_
_start: mov edx,len ;string length D I`
M
mov ecx,msg ;string start f[S$Gu4-
mov ebx,1 ;file handle: stdout
N\Nw mx
mov eax,4 ;sys_write ry99R|/d1
int 80h ;kernel system call pUTC~|j%:
j?eWh#[K"
mov ebx,0 ;return value {'(1c)q>
mov eax,1 ;sys_exit WnATgY t
int 80h ;kernel system call u+U '|6)E
I\8f`l
]g}Tqf/N%
x86 CPU,Windows,MASM32 ]t4 9Efw
.386 _1<zpHp
.model flat,stdcall G{4~{{tI
option casemap:none F0&BEJBkU
;Include 文件定义 7&I+mw/X
include windows.inc RU r0K#]
include user32.inc 6[iu CMOZ
includelib user32.lib |.8lS3C
include kernel32.inc 6Vq]AQx
includelib kernel32.lib KN41kkN
;数据段 aWtyY[=
.data SL(
WE=H
szCaption db 'A MessageBox!',0 ^N{Lau
szText db 'Hello,world!',0 +x?_\?&Ks
;代码段 _b ~XBn
.code 7mUpn:U
start: \&|zD"*
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK
k{{ iF
invoke ExitProcess,NULL i2h,=NHJh?
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> w_*UFLMSqR
end start !;[cm|<