“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 ydFZ$W_}w
8Qtd,
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 >q0c!,Ay
4$D:<8B
以下是用不同语言写成的Hello World程序的几个例子: ^i}*$ZC72
Ada _&s37A&\
with Ada.Text_Io; use Ada.Text_Io; aKdi
procedure Hello is <t[WHDO`
begin S'"(zc3=
Put_Line ("Hello, world!"); ~Y^
UP
end Hello; ?0HPd5=<v
^M60#gJ
u\gPx4]4c
汇编语言 _bp9UJ
NWCJ|
x86 CPU,DOS,TASM Wt2+D{@8
MODEL SMALL ]DcQ8D
IDEAL ao>`[-
STACK 100H i}mvKV?!|1
FL-yt
DATASEG 0mj^Tms
HW DB 'Hello, world!$' yeQ6\yi
i6F`KF'i&
CODESEG ptXCM[Z+
MOV AX, @data %G!BbXlz
MOV DS, AX /lBx}o'
MOV DX, OFFSET HW > D:(HWL
MOV AH, 09H GY9CU=-
INT 21H A
i`
MOV AX, 4C00H PfKIaW<
INT 21H ;<qv-$P
END {%!.aQ,
`8$gaA*
XBi}hT
x86 CPU,GNU/Linux,NASM C^vB&3ghi
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). Y{~[N y E
;Enter this into "hello.asm" then type: Cf#[E~2 4
;"nasm -f elf hello.asm" fg1_D
;"ld hello.o -o hello" C^>txui8
;"./hello" 0. _)X
Ph(bgQg
section .data ;data section declaration ~Xa8\>
msg db 'Hello World!',0AH $@y<.?k>UP
len equ $-msg ;string length EN^C'n
A*)G. o:
section .text ;code section declaration A8bDg:G1i
global _start ;entry point (start of execution) ;E? Z<3{
_start: mov edx,len ;string length ]=T`8)_r)
mov ecx,msg ;string start k.b->U
mov ebx,1 ;file handle: stdout DpG|Kl|d
mov eax,4 ;sys_write 7;H!F!K]
int 80h ;kernel system call +z/_'DE
gc|?$aE
mov ebx,0 ;return value 4Eq$f (QJ
mov eax,1 ;sys_exit |fYr*8rH
int 80h ;kernel system call dq$H^BB+>
P[NAO>&t