“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 a^|9rho<
6}Tftw$0z
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 Lu:*nJ%1[
.0RQbc9
以下是用不同语言写成的Hello World程序的几个例子: +boL?Ix+
Ada nxBP@Td
with Ada.Text_Io; use Ada.Text_Io; [tJn!cMs
procedure Hello is u-s*k*VHoc
begin ,}@4@ >?K
Put_Line ("Hello, world!"); zVf79UrK
end Hello; On~KTt3Mp
rc<Ix
d4ld-y
汇编语言 tKcC{
G4P*U3&p
x86 CPU,DOS,TASM K1A<m=If
MODEL SMALL Ii5U)"
IDEAL
!sEhjJV^7
STACK 100H 1 I.P7_/
~Ey+
DATASEG
FXn98UF Y
HW DB 'Hello, world!$' 8Dtpb7\o
r-L& ee
CODESEG <82&F
MOV AX, @data e1E_$oJP
MOV DS, AX oQ/T5cOj
MOV DX, OFFSET HW oIx|)[
MOV AH, 09H >`a^E1)
INT 21H Vp~ cN
MOV AX, 4C00H 6|
o S 5
INT 21H @RszPH1B
END H25Qx;(dTk
pjTJZhT2 I
gp{C89gP
x86 CPU,GNU/Linux,NASM SiaW; ks
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). <-b9
)>
;Enter this into "hello.asm" then type: #qF1z}L(
;"nasm -f elf hello.asm" Sw"h!\c`
;"ld hello.o -o hello" .I_<\h7
;"./hello" 5p}j{f
_>;MQ)Km~
section .data ;data section declaration $oM>?h_=
msg db 'Hello World!',0AH 1L'Q;?&2H,
len equ $-msg ;string length 3RGmmX"?G
@R%qP>_
section .text ;code section declaration IQtQf_"e1
global _start ;entry point (start of execution) {r;_nMfH|[
_start: mov edx,len ;string length kRwUR34yc
mov ecx,msg ;string start X=abaKl
mov ebx,1 ;file handle: stdout f~Pce||e
mov eax,4 ;sys_write uM_ww6
int 80h ;kernel system call uKXD(lzX
"M-';;
mov ebx,0 ;return value U*\K<fw
mov eax,1 ;sys_exit l4r>#n\yj
int 80h ;kernel system call s$fX
;
Ai[@2A yU
K$qY^oyQFw
x86 CPU,Windows,MASM32 Me?I8:/
.386 k[D,du')
.model flat,stdcall jVN06,3z
option casemap:none #-f9>S9_
;Include 文件定义 ZYY2pY 1
include windows.inc P*7G?
include user32.inc G rU`;M"
includelib user32.lib 5psJv|Zo]
include kernel32.inc Q4LPi;{\
includelib kernel32.lib YG8C<g6E7
;数据段 (tVT&eO
.data MI(#~\Y~P
szCaption db 'A MessageBox!',0 *P7/ry^<F
szText db 'Hello,world!',0 siCm)B
;代码段 G,$nq4
.code b-#{O=B
start: n&P~<2^M#
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK !
M CV@5$
invoke ExitProcess,NULL ;ZAwf0~
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Il*!iX|23<
end start *U$]U0M
<dD!_S6@,
C,eP!_O
AWK Nr$78] o9
BEGIN { print "Hello, world!" } R_+:nCB@,
D QxuV1
1Hr1Ir<KR
BASIC W]7<PL*u
传统版BASIC(例如GWBASIC): i \/'w]
1_f+!
ns#
10 PRINT "Hello, world!" NNqvjM-
20 END k,=<G,
}}]Lf 3;
或在提示符输入: _Y&.Nw
yn]Sc<uK
?"Hello, world!":END Lhux~,EH
pKq[F*Lut
现代版BASIC(例如Quick BASIC): 4XER7c
x=7:D
Print "Hello, world!" u=v-,Tw
Y %bb-|\W
以下的语句在Quick BASIC中同样有效: B&rN