“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 sZBO_](S
3v+}YT{>b
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 "hY^[@7 W
[m[~A|S
以下是用不同语言写成的Hello World程序的几个例子: Dx*oSP.qX
Ada GJfNO-
with Ada.Text_Io; use Ada.Text_Io; 'c(Y")QP
procedure Hello is ~cj:AIF
begin ~0GX~{;r
Put_Line ("Hello, world!"); @_ZWP
end Hello; Jd6Q 9~z#
;OqLNfU3y
.T wF]v
汇编语言 vbh#[,lh
n7.lF
x86 CPU,DOS,TASM NfN6KDd]2L
MODEL SMALL i j;'4GzQL
IDEAL z( [ $,e\
STACK 100H l8us6
EoWzHa
DATASEG
VZ@@j[F(
HW DB 'Hello, world!$' ;QD;5
<1
1U9N8{xg9
CODESEG 1+c(G?Ava
MOV AX, @data *]?YvY
MOV DS, AX }mZ*f y0t
MOV DX, OFFSET HW >(KUYX?p
MOV AH, 09H 1RHH<c%2n
INT 21H t1g%o5?;
MOV AX, 4C00H @|A&\a-"J
INT 21H m?G+#k;K
END &scD)
BTtYlpN6
{j*+:Gj0V
x86 CPU,GNU/Linux,NASM 9gayu<J
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). IFoN<<7/2$
;Enter this into "hello.asm" then type: oioN0EuDk
;"nasm -f elf hello.asm" Ps4A
B#3
;"ld hello.o -o hello" ` &7?+s
;"./hello" ]r5Xp#q2
1K',Vw_
section .data ;data section declaration iqP0=(^m
msg db 'Hello World!',0AH xl=|]8w
len equ $-msg ;string length )PNk
O3
90D.G_45
section .text ;code section declaration X]%4QIeS
global _start ;entry point (start of execution) o;/F=Zp
_start: mov edx,len ;string length :8T@96]P
mov ecx,msg ;string start G=Bj1ss.
mov ebx,1 ;file handle: stdout Y%8QFM
mov eax,4 ;sys_write RM$S|y{L
int 80h ;kernel system call me\)JCZpb{
n:z>l,`C]
mov ebx,0 ;return value ?KW?] o
mov eax,1 ;sys_exit s5#g[}dj
int 80h ;kernel system call 824%]i3
:$d 3a"]
1nG"\I5N}
x86 CPU,Windows,MASM32 0_izTke
.386 y%Ah"UY
.model flat,stdcall aKcV39brr
option casemap:none Q-CVq_\3I
;Include 文件定义 7@]hu^)rry
include windows.inc #]^`BQ>
include user32.inc ^@eCT}p{
includelib user32.lib Z6pDQ^Ii
include kernel32.inc {a%cU[q
includelib kernel32.lib NKYyMHv6
;数据段 w=2X[V}
.data EJY:C9W
szCaption db 'A MessageBox!',0 @Q5^Q'!
szText db 'Hello,world!',0 q\Z1-sl~s
;代码段 |9M
y>8k(
.code EatDT*!
start: aW5~z^I
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK i?9Lf
invoke ExitProcess,NULL UQr+\ u
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Id1[}B-T
end start 8yl/!O,v
tJ3s#q6
2Z |kf9
AWK |3@]5f&
BEGIN { print "Hello, world!" } [r'M_foga*
B9\o:eY
9a unv
BASIC ktb.fhO
传统版BASIC(例如GWBASIC): 2YQ$hL ~
$E6uA}s
10 PRINT "Hello, world!" H&+s&