“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 +_bxza(ma{
ZUS5z+o
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 xaoR\H
(&r`
l&0
以下是用不同语言写成的Hello World程序的几个例子: c|aX4 =Z
Ada W(4$.uZ)
with Ada.Text_Io; use Ada.Text_Io; g.%} +5
procedure Hello is s3Zt)xQ3
begin cjO%X
Put_Line ("Hello, world!"); .sM,U
end Hello; oqhJ2
xJU]py~o
*_#2|96)
汇编语言 S&XlMu
6\I1J=
C
x86 CPU,DOS,TASM t?PqfVSq
MODEL SMALL ScD
E)r
IDEAL &.s.g\
STACK 100H 3T,[
a8ouk7G
DATASEG 6oZHSjC*
HW DB 'Hello, world!$' ]o0]i<:
WvfM.D!
CODESEG cS:O|R#%t
MOV AX, @data UpE+WzY
MOV DS, AX ^?sP[;8S!
MOV DX, OFFSET HW F.1u9)
MOV AH, 09H e?B}^Dk0i
INT 21H $@]
xi
MOV AX, 4C00H ZnzO]
INT 21H Kz/,V6H:
END S^==$TT
N!wuBRWR
_`^AgRE
x86 CPU,GNU/Linux,NASM pnz: <V"Y(
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). &IzNoB
;Enter this into "hello.asm" then type: >$-YNZA
;"nasm -f elf hello.asm" -\;0gnf{J
;"ld hello.o -o hello" t0@AfO.'1
;"./hello" Jp}\@T.
5p:BHw;%;
section .data ;data section declaration -@`Ah|m@}
msg db 'Hello World!',0AH .`*]nN{
len equ $-msg ;string length 19y,O0# _
3#dz6+
section .text ;code section declaration C#yRop_d]o
global _start ;entry point (start of execution) FBB<1( {A
_start: mov edx,len ;string length G}+@C]
mov ecx,msg ;string start \f(zMP
mov ebx,1 ;file handle: stdout E"S#d&9
mov eax,4 ;sys_write |o9`h 9i
int 80h ;kernel system call u7RlxA:
w%iwxo
mov ebx,0 ;return value `sso Wn4
mov eax,1 ;sys_exit W}3%BWn
int 80h ;kernel system call %D:VcY9OC
S$$SLy:P
Cojs;`3iF:
x86 CPU,Windows,MASM32 t^zE^:06
.386 :3
Hz!iZM
.model flat,stdcall tvFe_*Ck
option casemap:none d4^x,hzV
;Include 文件定义 '7oCWHq[
include windows.inc ITqAy1m@C
include user32.inc 6_u!{
includelib user32.lib Y*\h?p[,
include kernel32.inc 8IxIW0
includelib kernel32.lib & /T}
;数据段 m;>G]Sbe
.data <Lxp t
szCaption db 'A MessageBox!',0 w{xa@Q]t-
szText db 'Hello,world!',0 !o?&{"#+
;代码段 jIrfJ*z
.code $':5uU1}
start: UQ;2g\([
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK ty"L&$bf
invoke ExitProcess,NULL Z4As'al
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> %cUC~, g_(
end start 00dY?d{[D
]cS(2hP7
a)=|{QR>W
AWK O< /b]<[
BEGIN { print "Hello, world!" } kBrA ?
F!u)8>s+z{
se2Y:v
BASIC \aM-m:J
传统版BASIC(例如GWBASIC): _a& Z$2O
Z8Y&#cB
10 PRINT "Hello, world!" PI`Y%! P
20 END 9@q!~ur
_b-g^#L%
或在提示符输入: Qb>("j~Z
)uo".n|n~B
?"Hello, world!":END 3%GsTq2o
$|J+
现代版BASIC(例如Quick BASIC): XxdD)I
6Y,&