“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 *~\R0ddz
U~GQ JR
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 YHOo6syk
M~ku4ZP
以下是用不同语言写成的Hello World程序的几个例子: NiSH$MJ_
Ada [vTk*#Cl4
with Ada.Text_Io; use Ada.Text_Io; l<)k`lrMX4
procedure Hello is 9SQcChG~j
begin 2r"J"C
Put_Line ("Hello, world!"); P^57a?[`
end Hello; ' 4.T1i,
tyU'[LF?
?p'DgL{
汇编语言 w(oi6kg
})yB2Q0
x86 CPU,DOS,TASM U}R(
MODEL SMALL V0G"Z6
IDEAL H(gETRh
STACK 100H ae>B0#=
`LOW)|6r`
DATASEG I&9Itn p$
HW DB 'Hello, world!$' UBWUq
\ RS
,Y
CODESEG eXAJ%^iD
MOV AX, @data _$P1N^}Zs
MOV DS, AX 0^83:C
^{
MOV DX, OFFSET HW 7V2xg h!W
MOV AH, 09H O?$]/d
INT 21H ?Q~o<%U7
MOV AX, 4C00H LaX<2]Tx:
INT 21H m0p%R>:5
END Fv-~v&
J3XrlSc
Tn"^`\m
x86 CPU,GNU/Linux,NASM uE,g|51H/
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). tF:AqR:(~
;Enter this into "hello.asm" then type: w_P2\B^
;"nasm -f elf hello.asm" `hf`lq^
;"ld hello.o -o hello" (>SucUU
;"./hello" O?t49=uB}
-<l2 $&KS
section .data ;data section declaration Wi@YJ
msg db 'Hello World!',0AH oV'G67 W
len equ $-msg ;string length I+/fX0-Lib
:E.T2na
section .text ;code section declaration im@QJ:
global _start ;entry point (start of execution) !;Vqs/E
_start: mov edx,len ;string length X?.tj
Z,
mov ecx,msg ;string start MNf^ml[
mov ebx,1 ;file handle: stdout 1G8,Eah
mov eax,4 ;sys_write Vt(s4
int 80h ;kernel system call `>&K=C?
k_`h (R
mov ebx,0 ;return value U&W/Nj
mov eax,1 ;sys_exit snYyxi
int 80h ;kernel system call j@R"AP}
* .g[vCy
@a i2A|
x86 CPU,Windows,MASM32 9y*2AaxW
.386 5KTPlqm0qF
.model flat,stdcall 6[,7g&C
option casemap:none @77+K:9I7
;Include 文件定义 eig{~3
include windows.inc g?N^9B,$2
include user32.inc |RL\2j|
includelib user32.lib ,W BKN)%u
include kernel32.inc iu.Jp92
includelib kernel32.lib 8?1MnjhX10
;数据段 6^)eW+
.data {_4`0J`3
szCaption db 'A MessageBox!',0 >en\:pJn)'
szText db 'Hello,world!',0 On0,#i=
;代码段 <;*w97n
.code u6 Yp,!+
start: TN/y4(j
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK pM9M8d
invoke ExitProcess,NULL ]app 9
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #nq_R
end start %-[*G;c'w
=fJ /6
&