“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 W%.ou\GN^t
A\S1{JrR
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 >~)IsQ*%
\8HLQly|@
以下是用不同语言写成的Hello World程序的几个例子: 'V-_3WWxU
Ada 7Ew.6!s#n1
with Ada.Text_Io; use Ada.Text_Io; r1o_i;rg
procedure Hello is I,0Z* rw
begin = m6yH_`@
Put_Line ("Hello, world!"); 1p]Z9$Y
end Hello; IP
e"9xb
cV+x.)a.
w\f>.N
汇编语言 kV$$GLD\
Ohe*m[
x86 CPU,DOS,TASM WG\gf\= I
MODEL SMALL V {H/>>k7
IDEAL [WxRwE
STACK 100H H6Qb]H.C
]Y%U5\$
DATASEG ujMics(
HW DB 'Hello, world!$' UC{Tm f
cy+EJq I
CODESEG #ekz>/Im*
MOV AX, @data ^,;AM(E
MOV DS, AX M(+;AS?;
MOV DX, OFFSET HW g\O&gNq<)-
MOV AH, 09H ]0yYMnqvr
INT 21H |fTWf}Jx
MOV AX, 4C00H @Y8/#6KE
INT 21H ( 8}'JvSu
END hr)CxsPoRQ
sH}q &=
:lGH31GG
x86 CPU,GNU/Linux,NASM 057$b!A-a
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). h~zG*B5F
;Enter this into "hello.asm" then type: |m5 E%E
;"nasm -f elf hello.asm" qV`JZ\n
;"ld hello.o -o hello" `OP?[
f d
;"./hello" ?*ni5\y5o
'dFhZ08u}
section .data ;data section declaration P
O{1u%P
msg db 'Hello World!',0AH RXDPT
len equ $-msg ;string length fvUD'sx
C"=^(HU
section .text ;code section declaration HvSYE[Zt|
global _start ;entry point (start of execution) Edi`x5"l
_start: mov edx,len ;string length }[%d=NY
mov ecx,msg ;string start ])YGeY(V0+
mov ebx,1 ;file handle: stdout YEB@ p.
mov eax,4 ;sys_write
:Ky
*AI
int 80h ;kernel system call {ylhh%t4hi
Zagj1OV|
mov ebx,0 ;return value _a e&@s1
mov eax,1 ;sys_exit =cN!h"C[
int 80h ;kernel system call _=\=oC
/e0cx:.w
qauZ-Qoc9
x86 CPU,Windows,MASM32 QaMB=wVr
.386 AHA4{Zu[
.model flat,stdcall l*+5WrOS
option casemap:none _P]!J~$5
;Include 文件定义 ZJ7<!?6
include windows.inc xQetAYP`
include user32.inc |8s)kQ4$
includelib user32.lib &