“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 M`_RkDmy<
;^fGQ]`4
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 c:[z({`
I[P43>F3
以下是用不同语言写成的Hello World程序的几个例子: Ii*tux!S
Ada 1W@ C]n4
with Ada.Text_Io; use Ada.Text_Io; k
5~#_D>
procedure Hello is h`{agWB
begin 0j@nOj(3
Put_Line ("Hello, world!"); #ZzFAt
end Hello; W>^WNo3YQ$
&
B
CA
kMJf!%L (
汇编语言 ,Z_aZD4
YB;q5[
x86 CPU,DOS,TASM ?o0ro?9j
MODEL SMALL $_ &Lp\
IDEAL .k_>
BD];
STACK 100H Z{Si`GA
U;PGBoe
DATASEG [SJ-]P|^l
HW DB 'Hello, world!$' M{!Y
J #ukH`|-
CODESEG )iKV"jsC
MOV AX, @data pv3SAO4
MOV DS, AX /"Z6\T9
MOV DX, OFFSET HW __B`0t
MOV AH, 09H Rix|LKk{
INT 21H 2b&&3u8
MOV AX, 4C00H 9n\b!*x
INT 21H u;@~P
END PM(M c]6
+1uAzm4SL
7dg2-4
x86 CPU,GNU/Linux,NASM [unK5l4_!
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). QGC%, F"+
;Enter this into "hello.asm" then type: Un~
}M/
;"nasm -f elf hello.asm" >^fpQG
;"ld hello.o -o hello" 6ct'O**k*&
;"./hello" 'MWu2L!F
XWuHH;~*L
section .data ;data section declaration VLL CdZ%
msg db 'Hello World!',0AH pbXh}YJ&
len equ $-msg ;string length vJ&g3ky
V"A*k^}
section .text ;code section declaration tAi
~i;?
global _start ;entry point (start of execution) N*B_or
_start: mov edx,len ;string length b$*1!a
mov ecx,msg ;string start GC#s;X
mov ebx,1 ;file handle: stdout #8{U0 7]"
mov eax,4 ;sys_write [9-&Lq_ g
int 80h ;kernel system call M15jwR!:M
^9jrI
mov ebx,0 ;return value <SPT2NyX
mov eax,1 ;sys_exit G(Ky7SZ
int 80h ;kernel system call !0}SZ
%U<