“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。
WB?HY?[r
*<W8j[?
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 (5 @H
v+"4YIN
以下是用不同语言写成的Hello World程序的几个例子: w6Nnx5Ay
Ada SF&2a(~s
with Ada.Text_Io; use Ada.Text_Io; 5e$1KN`
procedure Hello is JC%&d1
begin 4MS#`E7LrC
Put_Line ("Hello, world!"); s:7/\h
end Hello; Jn^b}bk t
Hc=QSP
C6[W/,eS
汇编语言 t+}wTis
Bp_R"DS7A
x86 CPU,DOS,TASM (z>t 4(%\
MODEL SMALL i?Pnyi
IDEAL ,bXZ<RY$
STACK 100H C= V2Y_j
1Vdi5;dn
DATASEG 8'zZVX D<
HW DB 'Hello, world!$' y7M{L8{0
z,4mg6gt
CODESEG sa4w.9O1GS
MOV AX, @data J6n>{iE
MOV DS, AX s6@mXO:H^
MOV DX, OFFSET HW E I zy
MOV AH, 09H ?' .AeoE-
INT 21H jZzTnmm&?
MOV AX, 4C00H 1'\QD`M9^
INT 21H X0u,QSt'O
END q9_$&9
1f}(=Hv{
uD>=
x86 CPU,GNU/Linux,NASM qEr?4h
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). \O;2^
;Enter this into "hello.asm" then type: `,-mXxTNT
;"nasm -f elf hello.asm" VwE4:/7YN
;"ld hello.o -o hello" HKXC=^}x'
;"./hello" D<;~eZ'
<;S$4tux
section .data ;data section declaration ![^pAEgx
msg db 'Hello World!',0AH YND }P9 h
len equ $-msg ;string length )Q'E^[Ua
lb.Q^TghU
section .text ;code section declaration 6sSwSS
global _start ;entry point (start of execution) <'~m1l#2
_start: mov edx,len ;string length [&