“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 ]JOephX2R
"mP&8y9F
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 !Citzor
0y)}.'
以下是用不同语言写成的Hello World程序的几个例子: o4$Ott%Wm
Ada gfi
AK%
with Ada.Text_Io; use Ada.Text_Io; KX!i\NHz
procedure Hello is 6gXIt9B.h$
begin l0I}&,+
Put_Line ("Hello, world!"); vt//)*(.$
end Hello; _`H.h6h
K&*iw`
z9[[C^C
汇编语言 Y RPm^kW
7 _`L$<-n
x86 CPU,DOS,TASM J , V
MODEL SMALL pgT9hle/
IDEAL [`d$X^<y;
STACK 100H p8Iw!HE
7_-w_"X
DATASEG 0axxQ!Ivx
HW DB 'Hello, world!$' q# MM
!lAD
q|$
CODESEG (ab{F5
MOV AX, @data !BDUv(
MOV DS, AX 2K;#Evn'j
MOV DX, OFFSET HW Z1M>-[j)
MOV AH, 09H Frk c O
INT 21H F!JJ6d53y
MOV AX, 4C00H BPqk"HG]T
INT 21H 7|YN:7iA
END @:Di`B_{
%%>_B2vc
D3`}4 A
x86 CPU,GNU/Linux,NASM Br}h/!NU/
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). \i!Son.<
;Enter this into "hello.asm" then type: ,|+Gls
;"nasm -f elf hello.asm" vv6?V#{
;"ld hello.o -o hello" j Fma|y
;"./hello" EM@;3.IO
ibJHU@l
section .data ;data section declaration -T7xK/
msg db 'Hello World!',0AH 4[TR0bM%
len equ $-msg ;string length 9Y/L?km_(
b;#\~(a
section .text ;code section declaration 3o*FPO7?
global _start ;entry point (start of execution) 6k"P&AD
_start: mov edx,len ;string length IS BV%^la|
mov ecx,msg ;string start V }>n
mov ebx,1 ;file handle: stdout RsW9:*R
mov eax,4 ;sys_write Rs*vm
int 80h ;kernel system call $<|ocUC7
X eoJ$PfT
mov ebx,0 ;return value 9XX>A*
mov eax,1 ;sys_exit K^zDNIQU
int 80h ;kernel system call 6 "U8V?E
-I":Z2.fR
C9qJP^F
x86 CPU,Windows,MASM32 4,G w#@
.386 |ETiLR=&
.model flat,stdcall ][d,l\gu+s
option casemap:none y:d{jG^
;Include 文件定义 ;gMgj$mI
include windows.inc
F[saP0
*
include user32.inc n,j$D62[
includelib user32.lib /4$4h;_8
include kernel32.inc M\oTZ@
includelib kernel32.lib e}0:"R%E
;数据段 u=r`t(Z1H
.data [I l~K
szCaption db 'A MessageBox!',0 /\Z J
szText db 'Hello,world!',0 e8}Ezy"^
;代码段 MgJ36zM
.code ]JE TeZ^/
start: |>2FRPK
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK JN'cXZJPn
invoke ExitProcess,NULL G^wtE90
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 7\XE,;4>
end start 9b;A1gu
QvLZg
-"Q-H/qh
AWK 9 [jTs3l:
BEGIN { print "Hello, world!" } 5,pSg
%zeATM[`
C`V)VJM
BASIC T*~H m
传统版BASIC(例如GWBASIC): %UZVb V
^j )BKD-
10 PRINT "Hello, world!" K93p"nHN
20 END ]"~51HQZ
X"q!Y#)
或在提示符输入: w$|l{VI
bU54-3Ox*
?"Hello, world!":END hWo=;#B*
]3Dl)[R
现代版BASIC(例如Quick BASIC): ,xI%A,
(,;
'b/<