“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 +(Hp ".gU
&b:y#gvJ:
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 xH28\]F5n
|#t^D.j
以下是用不同语言写成的Hello World程序的几个例子: L}Sb0 o.
Ada U43U2/^
with Ada.Text_Io; use Ada.Text_Io; `;G@qp:A
procedure Hello is HqqMX`Rof
begin !b0A%1W;
Put_Line ("Hello, world!"); 0 7qjWo/t
end Hello; 0;1O;JRw
Ot=nKdP}D
4VF]tX?o
汇编语言 ' p!&&.%
#Q_Scxf
x86 CPU,DOS,TASM ?gAwMP(>
MODEL SMALL V`/c#y||
IDEAL fZap\
STACK 100H $&,
KZ>
m5J@kE%
DATASEG ]n1#8T&<*z
HW DB 'Hello, world!$' '%|Um3);0p
sjLm-pn3
CODESEG Zl#';~9W
MOV AX, @data /3Y"F"`M.
MOV DS, AX 2sqH
>fen
MOV DX, OFFSET HW xG4 C 6s
MOV AH, 09H R'_F9\
INT 21H V@G|2ZI
MOV AX, 4C00H p+nB@fN/
INT 21H u&`rK7J
END iqX%pR~Yo
66WJ=?JV
Hjs#p{t[
x86 CPU,GNU/Linux,NASM X+\=dhn69
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). .db:mSrL
;Enter this into "hello.asm" then type: [p0_I7
;"nasm -f elf hello.asm" P
2x.rukT|
;"ld hello.o -o hello" #="Lr4T
;"./hello" )ARV>(
-:!T@rV,d
section .data ;data section declaration w2!5TKZ`
msg db 'Hello World!',0AH Z_jV0[\v0P
len equ $-msg ;string length @v6{U?
?5 6;<%0
section .text ;code section declaration h=au`o&CG
global _start ;entry point (start of execution) F CfU=4O
_start: mov edx,len ;string length 44B9JA7u
mov ecx,msg ;string start
|M?VmG/6
mov ebx,1 ;file handle: stdout R6o07.]
mov eax,4 ;sys_write 7S_"h*Ud
int 80h ;kernel system call ,0,&
L
q+4<"b+6G
mov ebx,0 ;return value `9f7H
mov eax,1 ;sys_exit
6l|SGt\
int 80h ;kernel system call '<C#"2
]INt9Pvqm
*ES"^N/88
x86 CPU,Windows,MASM32 :N4?W}r.
.386 UPuG&A#VV
.model flat,stdcall I'R|B\
option casemap:none Pf<BQ*n
;Include 文件定义 y8di-d3_
include windows.inc ,f~8:LHq
include user32.inc cbx(
L8
includelib user32.lib /-ewCCzZV
include kernel32.inc j4D`Xq2X
includelib kernel32.lib =~$)Ieu
;数据段 !V0)eC50
.data 3)dtl!VMW[
szCaption db 'A MessageBox!',0 A LR`z~1
szText db 'Hello,world!',0 <qx qlEQT
;代码段 x@VZJrQQ
.code 2cJ3b
0Xx
start: sGbk4g
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK u,S}4p&l
invoke ExitProcess,NULL `hl1R3nBM
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Oufdi3h
end start d
a.6Z!a
^;mGOjS
>56;M7b(K
AWK EK^["_*A
BEGIN { print "Hello, world!" } X&