“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 NFur+zwv
BTA2['
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 y^{4}^u-^
\j
we
以下是用不同语言写成的Hello World程序的几个例子: 5(Q-||J
Ada FS?1O"_
with Ada.Text_Io; use Ada.Text_Io; Skux&'N:
procedure Hello is !([ v=O#
begin 2Qp]r+!
Put_Line ("Hello, world!"); C<^S$
end Hello; b3GTsX\2|
6is+\
rg%m
汇编语言 D[YdPg@-
9(Kff nE^
x86 CPU,DOS,TASM ^:O*Sx.CA
MODEL SMALL 7
X~JLvN
IDEAL W^H[rX}=
STACK 100H X0$?$ta
@ <'a0)n>
DATASEG zRau/1Y0
HW DB 'Hello, world!$' %uP/v\l
h{)`W
]~
CODESEG n2F*a
MOV AX, @data &(x>J:b
MOV DS, AX N=8CVI
MOV DX, OFFSET HW p1z^i(
MOV AH, 09H ,~K4+
t_
INT 21H HE2t0sAYX
MOV AX, 4C00H !) d
INT 21H *9r 32]i;
END G%%F6)W
@$!"}xDR'
9*?YES'6
x86 CPU,GNU/Linux,NASM c8cGIAOY)
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). UyNP:q:
;Enter this into "hello.asm" then type: (i@(ZG]/
;"nasm -f elf hello.asm" t$Ua&w
;"ld hello.o -o hello" Hu!<GB~
;"./hello" B=%YD"FAv
N,cj[6;T%
section .data ;data section declaration _9/Af1X
msg db 'Hello World!',0AH <g8{LG0
len equ $-msg ;string length MB.LHIo
DsBZ%
section .text ;code section declaration Lg6>\Z4
global _start ;entry point (start of execution) 7H[.o~\
_start: mov edx,len ;string length WMoRosL74
mov ecx,msg ;string start # kmI#W"^
mov ebx,1 ;file handle: stdout 6<n+p'+n
mov eax,4 ;sys_write ia-&?
int 80h ;kernel system call (L<G=XC
BUsAEwM
mov ebx,0 ;return value J \I`#
mov eax,1 ;sys_exit 8O*O5
int 80h ;kernel system call 6
)Qe*S
dSzq}w4xY
k0DX|O8mXV
x86 CPU,Windows,MASM32 gLg\W3TOi
.386 d[ce3':z
.model flat,stdcall >P ygUY
d
option casemap:none C2J@] &