“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 p[hZ@f(z
RA KFU
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 w8kOVN2b
Fs{x(_LOr
以下是用不同语言写成的Hello World程序的几个例子: _CW(PsfY
Ada ^cczJOxB
with Ada.Text_Io; use Ada.Text_Io; Pl=ZRKn
procedure Hello is bn^{c
begin V n*
Put_Line ("Hello, world!"); DE%KW:Hug
end Hello; ]z l[H7
SS$[VV
Qa.<K{m#?
汇编语言 9[G[$c
<_3b1VhZ
x86 CPU,DOS,TASM ]}U*_rM:
MODEL SMALL 9?0^ap,T
IDEAL vg3=8>#
STACK 100H &;+-?k|
BReJ!|{m}
DATASEG .Nw=[
HW DB 'Hello, world!$' MC<PM6w
~ vJ,`?
CODESEG c2&q*]?l;
MOV AX, @data `}mcEl
MOV DS, AX {5F-5YL+>
MOV DX, OFFSET HW %kdEun
MOV AH, 09H +tVaBhd!
INT 21H OU8Lldt
MOV AX, 4C00H !Cr(Pe]
INT 21H .u4
W /
END z"0I>gl
w)Q0_2p.
hnDBFQ{
x86 CPU,GNU/Linux,NASM *g6n
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). EJsM(iG]~M
;Enter this into "hello.asm" then type: CC L
;"nasm -f elf hello.asm" VzY8rI
;"ld hello.o -o hello" @ Wd9I;hWv
;"./hello" i70wrW#k
|NpP2|4h
section .data ;data section declaration (H
->IV
msg db 'Hello World!',0AH \3pc"^W
len equ $-msg ;string length qYlhlHD
K%^V?NP*{Z
section .text ;code section declaration R)mu2^
global _start ;entry point (start of execution) 1+}{8D_F
_start: mov edx,len ;string length PX<J&rx
mov ecx,msg ;string start !*oi!ysU;O
mov ebx,1 ;file handle: stdout S/4^ d &Gr
mov eax,4 ;sys_write 'H
\9:7
int 80h ;kernel system call OH">b6>\
/f|X(docI
mov ebx,0 ;return value \lZf<