“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 (^oN, 7
BItH0r7
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 9;7Gzr6A"
O!!N@Q2g
以下是用不同语言写成的Hello World程序的几个例子: '8Cg2v5&w
Ada =kTHfdin&
with Ada.Text_Io; use Ada.Text_Io; qxB|*P`
procedure Hello is gLm,;'h%u
begin 3{)!T;W d
Put_Line ("Hello, world!"); ?;VsA>PV
end Hello; A(_HMqA]
nz|6CP
e@Mg9VwDc
汇编语言 &@K6;T
b)eoFc)lc
x86 CPU,DOS,TASM 1etT."
MODEL SMALL %oB0@&!mS
IDEAL ZIN1y;dJ
STACK 100H [QFAkEJ--o
h0R.c|g[
DATASEG IwXWtVL
HW DB 'Hello, world!$' kXV;J$1
G2<$to~{
CODESEG a,36FF~&
MOV AX, @data IaZmN.k*
MOV DS, AX L{&>,ww
MOV DX, OFFSET HW AJ+\Qs(0
MOV AH, 09H wBDHhXi0
INT 21H jG~-V<&
MOV AX, 4C00H :i4AkBNK
INT 21H 0K'{w]Q
END 2?Y8hm
$l2`@ia"
$PG(>1e
x86 CPU,GNU/Linux,NASM Qs '_\|/-
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). /qKA1-R}4
;Enter this into "hello.asm" then type: cLEd-{x
;"nasm -f elf hello.asm" -4[eZ>$A|
;"ld hello.o -o hello" 4E2#krE%
;"./hello" Sg$\ H
jzJQ/ZFS
section .data ;data section declaration Gphy8~eS
msg db 'Hello World!',0AH n}b{u@$
len equ $-msg ;string length ^k*%`iQ
[>N#61CV5
section .text ;code section declaration lz!(OO,g
global _start ;entry point (start of execution) 6cd!;Ca
_start: mov edx,len ;string length ftvu69f
mov ecx,msg ;string start ?wu@+
mov ebx,1 ;file handle: stdout @0]w!q
mov eax,4 ;sys_write 2Z(t/Zp>
int 80h ;kernel system call X- tw)
)ut$644R
mov ebx,0 ;return value Ni8%K6]z
mov eax,1 ;sys_exit (/At+MF3E
int 80h ;kernel system call ^vxx]Hji
BTD_j&+(
EnGh&]
x86 CPU,Windows,MASM32 #]dq^B~~
.386 gg.]\#3g
.model flat,stdcall &#JYh=#
option casemap:none 118lb]
;Include 文件定义 6fo\z2
include windows.inc @ R[K8
include user32.inc `*cqT
includelib user32.lib j85B{Mab&
include kernel32.inc m62Zta
includelib kernel32.lib w[F})u]E
;数据段 8nng^
.data Mk~U/oq
szCaption db 'A MessageBox!',0 e]nP7TIU
szText db 'Hello,world!',0 T ay226
;代码段 Auc&dpW
.code r!1f>F*dt
start: CuK>1_Dq
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK T_!F I29
invoke ExitProcess,NULL >-\^ )z
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> sBYDo{01
end start ZBR^$?nj
^\g.iuE
yH=<KYk
AWK 6/#+#T
BEGIN { print "Hello, world!" } 5Q
<vS"g
*=O]^|]2
9+MW13?
BASIC t
#Kucde
传统版BASIC(例如GWBASIC): KB^8Z@(+
F53
.g/[
10 PRINT "Hello, world!" g0"xG}d
20 END iZ>P>x\
p6NPWaBR
或在提示符输入: unc6 V%
yZ{N$ch5b
?"Hello, world!":END p:4-b"O
?A;RTM
现代版BASIC(例如Quick BASIC): O:8
u^TP
o2B|r`R
Print "Hello, world!" C+P.7]?&