“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 rGt]YG#C
`WC4:8
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 yGWl8\,j0
s5{H15
以下是用不同语言写成的Hello World程序的几个例子: JUDZ_cGr
Ada j!Ys/D
with Ada.Text_Io; use Ada.Text_Io; SI%J+Y7
procedure Hello is
#z.\pd
begin #=Xa(<t
Put_Line ("Hello, world!"); ujX\^c
end Hello; >b3IZ^SB#$
>dF #1
{ i3x\|
汇编语言 OEbZs-:
tVX|e2Y
x86 CPU,DOS,TASM n31nORx50
MODEL SMALL X%iqve"{nB
IDEAL wT;;B=u}G
STACK 100H R*LPwJuv
Ebi~gGo
DATASEG {/?{UbU
HW DB 'Hello, world!$' em^2\*sxpA
HP 3%CB
CODESEG <>-gQ9
MOV AX, @data ]>sMu]biH
MOV DS, AX .g}Y!
l
MOV DX, OFFSET HW Y%]g,mG
MOV AH, 09H 6~s{HI!
INT 21H c(?O E'
"Z
MOV AX, 4C00H MfLus40;n
INT 21H l{ fL~O
END EOqV5$+
ji ,`?
M5`m5qc3
x86 CPU,GNU/Linux,NASM /n,a0U/
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). *x2u
;Enter this into "hello.asm" then type: 3+U2oI:I
;"nasm -f elf hello.asm" X88I|Z'HIh
;"ld hello.o -o hello" 5/m*Lc+r
;"./hello" Ai)Q(]
Mwj7*pxUh
section .data ;data section declaration {Y]3t9!\
msg db 'Hello World!',0AH N;m62N
len equ $-msg ;string length _A]~`/0;`
#LwDs,J :
section .text ;code section declaration B]7QOf"
global _start ;entry point (start of execution) l`JKQk
_start: mov edx,len ;string length g8"{smP/
mov ecx,msg ;string start *;t_VlaZ
mov ebx,1 ;file handle: stdout T z+Y_
mov eax,4 ;sys_write MI8c>5?
int 80h ;kernel system call NH1|_2
n=!5ha%#N
mov ebx,0 ;return value )s 1
Ei9J
mov eax,1 ;sys_exit V-i:t,*lk(
int 80h ;kernel system call Hpp;dG
2PSv3?".
SnO,-Rg
x86 CPU,Windows,MASM32 Qej<(:J5
.386 J/ vcP
.model flat,stdcall EJaO"9
(
option casemap:none Gn10)Uf8X
;Include 文件定义 jJ_6_8#
include windows.inc SS,'mv
include user32.inc aMJ9U)wnK
includelib user32.lib @(tuE
include kernel32.inc <("P5@cExU
includelib kernel32.lib 3URrK[%x`
;数据段 ?nR$>a`
.data }T=\hM
szCaption db 'A MessageBox!',0 ,}Ic($To
szText db 'Hello,world!',0 (jE[W:
;代码段 \ $9n
`
.code hJ V*
start: <jVk}gi)Jp
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK k1FG$1.
invoke ExitProcess,NULL ~BI! l
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> hA"z0Fszh
end start ue}lAW{q
`jDmbD
+=
!{oP'8Ax$
AWK q]*:RI?wGT
BEGIN { print "Hello, world!" } f6HDfJmE
!un_JZD
pQ+4++7ID
BASIC j%*<W> O
传统版BASIC(例如GWBASIC): +(hr5
P$;_YLr
10 PRINT "Hello, world!" vnz}Pr! c
20 END 'cbD;+YH
9n".Q-V;k
或在提示符输入: ;|K(6)
3+%L[fW`/
?"Hello, world!":END |G-o&m"
'P-FeN^
现代版BASIC(例如Quick BASIC): RK=YFE 0
s0'Xih sw6
Print "Hello, world!" <