“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 "@P)
Hp#IOsP~
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 1FkS$ j8:
a9+l:c@
以下是用不同语言写成的Hello World程序的几个例子: vr:5+wew
Ada fz9
,p;b
with Ada.Text_Io; use Ada.Text_Io; /t4#-vz
procedure Hello is bu}N{cW
begin I%8>nMTJ
Put_Line ("Hello, world!"); ^]{)gk8P~2
end Hello; +*'^T)sj/
pGwBhZnb>
'}F=U(!
汇编语言 Hzn6H4Rc
pA~eGar_J
x86 CPU,DOS,TASM h;+bHrKji
MODEL SMALL JBvMe H5
IDEAL NFAjh?#
STACK 100H BEfP#h=hr
PQ}owEJ2eM
DATASEG ::&hfHR*P
HW DB 'Hello, world!$' ZcP/rT3{^
x/)o'#d$|l
CODESEG gq:2`W&5
MOV AX, @data 0q !
MOV DS, AX dXBXV>rbB
MOV DX, OFFSET HW )<>1Q{j@
MOV AH, 09H )C1ihm!7\
INT 21H +|iJQF
MOV AX, 4C00H saPg2N,
INT 21H IXz)xdP
END I<&(Dg|XQ
%]KOxaf_z
FN>ns,
x86 CPU,GNU/Linux,NASM xGBp+j1H
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). B]_NI=d
;Enter this into "hello.asm" then type: &Bc$8ZR
;"nasm -f elf hello.asm" W["c3c
;"ld hello.o -o hello" asLvJ{d8s
;"./hello" p10i_<J]=
@`D`u16]i
section .data ;data section declaration :wcv,YoSG
msg db 'Hello World!',0AH b-Uy&+:X*d
len equ $-msg ;string length Ra~|;(
%d
ww^!|VVa
section .text ;code section declaration @ /yQ4Gr
global _start ;entry point (start of execution) ]NRQM8\
_start: mov edx,len ;string length wpW3%r;9
mov ecx,msg ;string start Nfdh0v
mov ebx,1 ;file handle: stdout `yXJaTbo
mov eax,4 ;sys_write ]y52%RAKI
int 80h ;kernel system call y(2FaTjM
TM?RH{(r
mov ebx,0 ;return value nUy2)CL[L
mov eax,1 ;sys_exit T=-$ok`G
int 80h ;kernel system call aplOo[
Xv2u7T\
c1CUG1i
x86 CPU,Windows,MASM32 $ Lf-Gi
.386 |."thTO
.model flat,stdcall x_eR/B>
option casemap:none q<2b,w==
;Include 文件定义 r'/H3
include windows.inc {Bd 0
include user32.inc /CT g3Q"KQ
includelib user32.lib qE W3k),
include kernel32.inc ]"DsZI-glW
includelib kernel32.lib ^|+;~3<J
;数据段 g~Hmka_fD1
.data 1|8<!Hx#-
szCaption db 'A MessageBox!',0 g5,Bj
szText db 'Hello,world!',0 Qjl.O HO
;代码段 d_r1}+ao
.code y"o@?bny
start: MRn;D|Q
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK {;0+N -U
invoke ExitProcess,NULL .V.x0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> }c1?:8p
end start pndAXO:v
{YoK63b$
Bf-KCqC".
AWK <`/22S"
BEGIN { print "Hello, world!" } fkjo
(='e9H!3D
P+j5_ V{\b
BASIC qx+ .v2G
传统版BASIC(例如GWBASIC): <Jwx|
U<"@@``+N
10 PRINT "Hello, world!" cIJqF.k
20 END x_K8Gr#Z 0
^o@N.+`&<
或在提示符输入: S~+er{,ht4
`ywI+^b
?"Hello, world!":END / ~\ I
=8!FY"c*
现代版BASIC(例如Quick BASIC): :Q@qR((&o
j4fv-{=$
Print "Hello, world!" j$u=7Z&E
%0<-5&GE
以下的语句在Quick BASIC中同样有效: m\];.Da
f'>270pH
? "Hello,world!" HT:
p'Yyi
3tZC&!x?
@VVDN
BCPL GqT0SP
GET "LIBHDR" 9jC>OZ0s
$0OWPC1
LET START () BE VYj*LiR
$( 6L)]nE0^
WRITES ("Hello, world!*N") ;:/<