“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 z6#N f,
VO] Jvf
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 Q6@}t&k4C
]:(>r&'
以下是用不同语言写成的Hello World程序的几个例子: :WIbjI=
Ada !MSz%QcO
with Ada.Text_Io; use Ada.Text_Io; =unMgX]$
procedure Hello is M7-piRnd4
begin <"{Lv)4
Put_Line ("Hello, world!"); gQ3Co ./
end Hello; )tl=tH/$
*/sVuD^b`
yw^t6E
汇编语言 _v{,vLH
6^F"np{w
x86 CPU,DOS,TASM 0N$tSTo.-<
MODEL SMALL &Y%Kr`.h
IDEAL "%dWBvuO
STACK 100H \j !JRD+j
%Rj:r!XB:
DATASEG W?mn8Y;{`
HW DB 'Hello, world!$' QMea2q|3$
%_;q<@9)
CODESEG \u?z:mV
MOV AX, @data ;W]NT4p
MOV DS, AX Y$uXBTR`y/
MOV DX, OFFSET HW oe_l:Y%
MOV AH, 09H qUA&XUJ
INT 21H VJJGTkm
MOV AX, 4C00H q{@j$fMt0
INT 21H %Js3Y9AL C
END dRTtDH"%
767xCP
z)xGZ*{=
x86 CPU,GNU/Linux,NASM H$au02dpU
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). ks<gSCB
;Enter this into "hello.asm" then type: Idop!b5!
;"nasm -f elf hello.asm" A(X~pP&oF
;"ld hello.o -o hello" 5<w"iqZ\?N
;"./hello" uNZJNrV%
wvvMesX<L
section .data ;data section declaration }WS%nQA
msg db 'Hello World!',0AH )` -b\8uw
len equ $-msg ;string length ^Crl~~Gk`
,uqSq
section .text ;code section declaration AX}l~
sv
global _start ;entry point (start of execution) zk=5uKcPE
_start: mov edx,len ;string length 9#{?*c6
mov ecx,msg ;string start p/>}{Q )Y
mov ebx,1 ;file handle: stdout wcUf?`21,
mov eax,4 ;sys_write RKFj6u
int 80h ;kernel system call mV^+`GWvo
I$xfCu
mov ebx,0 ;return value G`!#k!&r
mov eax,1 ;sys_exit jG)fM?
int 80h ;kernel system call mj=$[y(
|UZPn>F~
9Xo'U;J
x86 CPU,Windows,MASM32 g#ubxC7t<
.386 ^eQK.B(
.model flat,stdcall o7S,W?;=5
option casemap:none <^6|ZgR
;Include 文件定义 %>`0hk88
include windows.inc YQe9g>G&
include user32.inc Rd|};-
includelib user32.lib GV#"2{t
j
include kernel32.inc EpSVHD:*
includelib kernel32.lib e#JJd=
;数据段 /*!K4)$-*2
.data =Y#)c]`
szCaption db 'A MessageBox!',0 9iGUE
szText db 'Hello,world!',0 }+G6` Zd
;代码段 5BR9f3}
.code gfG Mu0FjB
start: )pLde_ k
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK Zc(uK{3W-
invoke ExitProcess,NULL wG6>.`:
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> hd1(q33
end start iIji[>qz
Tn,'*D@l
XBe!9/'k>
AWK W}#eQ|oCV
BEGIN { print "Hello, world!" } }D/0&