“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 {Hxvt~P
H. U wM
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 9t:P1
a=}JW]
以下是用不同语言写成的Hello World程序的几个例子: G66A]FIg
Ada 8@S7_x
with Ada.Text_Io; use Ada.Text_Io; F[uy'~;@
procedure Hello is |y=; #A
begin W!|A3V35\:
Put_Line ("Hello, world!"); pcwkO
end Hello; mVFz[xI
-7\Rl3c
SEsc"l8
汇编语言 ckFnQhW
R
r7 r5
x86 CPU,DOS,TASM Rd7[e^HSN
MODEL SMALL <20rxOEnf
IDEAL 04>dxw)8
STACK 100H PI@/jh
Bwv@D4bii
DATASEG 7 \)OWp
HW DB 'Hello, world!$' ej-x^G?C
foY=?mbL
CODESEG c^0YuBps[
MOV AX, @data gn"Y?IZ?
MOV DS, AX 2(~Y ^_
MOV DX, OFFSET HW )f(.{M
MOV AH, 09H wG6@.;3
INT 21H ?0k(wiF
MOV AX, 4C00H DrE
+{Spm
INT 21H 2K?~)q&t*
END Fr/3Qp@S
f@U\2r
5A(zQ'6
x86 CPU,GNU/Linux,NASM ]l\'1-/
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). #LRN@?P
;Enter this into "hello.asm" then type: ~xI1@^r
;"nasm -f elf hello.asm" o|#Mq"od
;"ld hello.o -o hello" PR rf$& u
;"./hello" 8`Wj 1 ,q
V?"X0>]0
section .data ;data section declaration v"'Co6fw
msg db 'Hello World!',0AH m>dZ n
len equ $-msg ;string length Sj?u^L8es}
`tZu~
n
section .text ;code section declaration bH+x `]{A
global _start ;entry point (start of execution) +76{S_CZ
_start: mov edx,len ;string length ds@X%L;_
mov ecx,msg ;string start g=w,*68vuy
mov ebx,1 ;file handle: stdout A$*#n8,
mov eax,4 ;sys_write O%RkU?ME
int 80h ;kernel system call jSa9UD
TS0x8,'$q
mov ebx,0 ;return value X"QIH|qx-
mov eax,1 ;sys_exit 0uX"KL]Elf
int 80h ;kernel system call sjh>i>t
P(OgT/7A
&6!~Q,;K-
x86 CPU,Windows,MASM32 z.fh4p
.386 %JmRJpCvR
.model flat,stdcall _ 4:@+{
option casemap:none QP/6N9/
;Include 文件定义 [^wEKRt&
include windows.inc fBCW/<Z
include user32.inc E({+2}=1
includelib user32.lib u6&<Bv
include kernel32.inc r(sQI#
P
includelib kernel32.lib "-aak )7w
;数据段 JNhHQvi\
.data HU[a b
szCaption db 'A MessageBox!',0 0Y rdu,c
szText db 'Hello,world!',0 RiHOX&-7
;代码段 Wn;B ~
.code q-c9YOz_
start: Z9cg,#(D
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK [e1kfw
invoke ExitProcess,NULL Hg)5c!F7
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> l#7].-/
end start GdZ_
z@!z Q Vp
m)G=4kK52-
AWK RQ?T~ASs
BEGIN { print "Hello, world!" } f8]Qn8
]y&w