“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 <X^@*79m
#u(^0'
P
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 |`,2ri*5A
\fr~
以下是用不同语言写成的Hello World程序的几个例子: IH&|Tcf\
Ada V`d,qn)i
with Ada.Text_Io; use Ada.Text_Io; +wU@ynw
procedure Hello is S_4?K)n #
begin =^f<v_L
Put_Line ("Hello, world!"); FZ<gpIv!NS
end Hello; n;C
:0
_|\~q[ep
GPv1fearl
汇编语言 LTCb@L{^i
YnS#H"
x86 CPU,DOS,TASM T_
<@..C
MODEL SMALL S9D<8j^
IDEAL #PW9:_BE
STACK 100H oUr66a/[U
f4b/NG|
DATASEG $q{!5-e
HW DB 'Hello, world!$' _QE qk@ql
")5":V~fN
CODESEG J26V nK
MOV AX, @data El".I?E*
MOV DS, AX 7\[@m3s
MOV DX, OFFSET HW :T$|bc
MOV AH, 09H r~8 $1"
INT 21H t%FwXaO#
MOV AX, 4C00H <C iSK!
INT 21H ]t,BMu=%
END O`\;e>!t
@6sqMw}
Hqx-~hQO
x86 CPU,GNU/Linux,NASM KYhw OGN
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). hJ? O],4J
;Enter this into "hello.asm" then type: 9(7-{,c
;"nasm -f elf hello.asm" _p/UsJ
;"ld hello.o -o hello" aEWWP]
;"./hello" 1Z2HUzqh.
8z`G,qh
section .data ;data section declaration 4G0m\[Du
msg db 'Hello World!',0AH nYSiS}?S.
len equ $-msg ;string length |O+H[;TB6
7#a-u<HF"
section .text ;code section declaration *W1dG#Np}
global _start ;entry point (start of execution) F6|]4H.3Q
_start: mov edx,len ;string length 2tEkj=fA-
mov ecx,msg ;string start [Ek7b*
mov ebx,1 ;file handle: stdout M `M5'f
mov eax,4 ;sys_write aCj&O:]=
int 80h ;kernel system call :#ik. D
nEy&