“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 )pl5nu#<
S'!&,Dxq^
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 ,y]-z8J
v)Y)tu>
以下是用不同语言写成的Hello World程序的几个例子: K@7%i|H
Ada U*~-\jN1pb
with Ada.Text_Io; use Ada.Text_Io; B2kZ_4rB
procedure Hello is NWn*_@7;
begin QQW}.>N
Put_Line ("Hello, world!"); :6(\:
end Hello; f,yl'2{
dE"_gwtX
#HgNwM
汇编语言 UE^o}Eyg
=Q<VU/
x86 CPU,DOS,TASM aM
$2lR])J
MODEL SMALL ')v,<{
IDEAL H[hJUR+#
STACK 100H %"v:x?d$$o
Gl>\p
DATASEG Ypzmc$Xfu
HW DB 'Hello, world!$' F{jxs/~
J+t51B(a
CODESEG O(I^:_eH
MOV AX, @data Xr
K29a
MOV DS, AX ^<!R%"o-
MOV DX, OFFSET HW
ULt5Zi
MOV AH, 09H t[TM\j0jW
INT 21H iQ" LIeD
MOV AX, 4C00H -7&ywgxl
INT 21H _S{TjGZ&
END ei4LE
XQ16
U^KWRqt
!!Ww#x~k$[
x86 CPU,GNU/Linux,NASM ^gcB+
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). bdWdvd:
;Enter this into "hello.asm" then type: 48wt
;"nasm -f elf hello.asm" W7n^]~V
;"ld hello.o -o hello" YA
pC|R,^
;"./hello" ]<<,{IQ
v'?Smd1v
/
section .data ;data section declaration In1{&sS
msg db 'Hello World!',0AH }169]!R
len equ $-msg ;string length UdrgUqq)
!(q@sw(
section .text ;code section declaration KyrZ&E.`
global _start ;entry point (start of execution) A@>/PB6n
_start: mov edx,len ;string length :lXY% [!6P
mov ecx,msg ;string start ,+df=>$W
mov ebx,1 ;file handle: stdout t|'%0 W
mov eax,4 ;sys_write )ItABl[{
int 80h ;kernel system call [ifw}(
b\JU%89
mov ebx,0 ;return value F?'
mov eax,1 ;sys_exit .bY>++CAPA
int 80h ;kernel system call ZY,$oFdsi
'l(s)Oa{M:
/4(HVua
x86 CPU,Windows,MASM32 =!L}/Dl
.386 }kt%dDU
.model flat,stdcall L91vp'+2
option casemap:none f#&z