“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 !v;N@C3C
SZW`|ajH
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 8<z+hWX=4
1WRQjT=o
以下是用不同语言写成的Hello World程序的几个例子: 'kf]l=i[n
Ada E4GtJ`{X
with Ada.Text_Io; use Ada.Text_Io; Cb5;l~}L
procedure Hello is {M96jjiInf
begin u+a"
'*
Put_Line ("Hello, world!"); N?TXPY
end Hello; K>hQls+
//n$#c_}u
{b6| wQ\
汇编语言 eme7y
sygxV
x86 CPU,DOS,TASM 7)tkqfb]
MODEL SMALL uT:'Kkb!
IDEAL $(/=Wn
STACK 100H +e}v)N
CT,P Q
DATASEG Y S/x;
HW DB 'Hello, world!$' jD1/`g%
;c p*]
CODESEG 'c7C*6;a
MOV AX, @data f1s3pr??
MOV DS, AX U{/d dCf7
MOV DX, OFFSET HW Z0HfrK#oU
MOV AH, 09H p5`iq~e9
INT 21H LK\L}<;1V
MOV AX, 4C00H @yp#k>
INT 21H Cw6\'p%l-\
END 0M=A,`qk
(iQ<
[3C=
0z&]imU
x86 CPU,GNU/Linux,NASM @+Ch2Lod
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). .aS`l~6
;Enter this into "hello.asm" then type: KUJCkwQ
;"nasm -f elf hello.asm" mq
0 d ea
;"ld hello.o -o hello" K!W7a~
@
;"./hello" q:h7Jik
\#Md3!MG
section .data ;data section declaration 2%4u/
msg db 'Hello World!',0AH E2dl}S zp
len equ $-msg ;string length 6S K;1Bp-{
b9nTg
section .text ;code section declaration 1eHU!{<fqm
global _start ;entry point (start of execution) !r\u,l^
_start: mov edx,len ;string length >TI/W~M
mov ecx,msg ;string start >7g #e,d
mov ebx,1 ;file handle: stdout 'Ur1I"
mov eax,4 ;sys_write [$\KS_,Mn
int 80h ;kernel system call B&