“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 kE`V@F
1v2pPUH\
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 %'`L+y
:3h'Hr
以下是用不同语言写成的Hello World程序的几个例子: I4RUXi 5
Ada 3Y6W)$Q
with Ada.Text_Io; use Ada.Text_Io; Ao}J
procedure Hello is 3l?-H|T
begin R|OY5@
Put_Line ("Hello, world!"); }u9wD08x
end Hello; 079mn/8;
5<=ktA48[
L32 [IL|
汇编语言 2z+-vT%
miv)R
x86 CPU,DOS,TASM WPXLN'w+
MODEL SMALL L2P#5B!S
IDEAL f0Zn31c^
STACK 100H @+EO3-X5
jDKL}x
DATASEG
YgfQ{3^I
HW DB 'Hello, world!$' Vh o3I[C
Z7:TPY$b
CODESEG S#g=;hD
MOV AX, @data s ;N PY
MOV DS, AX Bq
9Eu1
MOV DX, OFFSET HW j$Unw
MOV AH, 09H _`LQnRp(
INT 21H }p$@.+
MOV AX, 4C00H FXd><#U
INT 21H #\LsM
~,
END @Q#<-/
T
7EkRcb
B!iz=+RNC1
x86 CPU,GNU/Linux,NASM '$m
uA\
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). %"{jNC?
;Enter this into "hello.asm" then type: U)B^R
;"nasm -f elf hello.asm" 2C@s-`b
;"ld hello.o -o hello" X@cO`P
;"./hello" /ltGSl
"1X@t'H38
section .data ;data section declaration b,MzHx=im
msg db 'Hello World!',0AH aW.[3M;?v
len equ $-msg ;string length [\ALT8vC?m
nPh|rW=
section .text ;code section declaration WY3D.z-</
global _start ;entry point (start of execution) %M
KZ':m
_start: mov edx,len ;string length }US^GEs(
mov ecx,msg ;string start //W7$DYEG
mov ebx,1 ;file handle: stdout z3+7gp+I;
mov eax,4 ;sys_write O>)Fl42IeD
int 80h ;kernel system call |^!
$V?h68[c
mov ebx,0 ;return value {=)g?!zC
mov eax,1 ;sys_exit 5q Y+^jO]o
int 80h ;kernel system call [Kc"L+H\
+#Q\;;FNP
hCvK2Xu
x86 CPU,Windows,MASM32 ;5TQH_g
.386 [(65^Zl`
.model flat,stdcall =k+nC)e
option casemap:none 0%f}w0]:
;Include 文件定义 d=~-8]%\
include windows.inc ?^l{t4
include user32.inc 52H'aHO1
includelib user32.lib b IZuZF>*
include kernel32.inc L2GUrf
includelib kernel32.lib ln~;Osb
;数据段 LFHzd@Y7"
.data 5UU1HC;C
szCaption db 'A MessageBox!',0 YA,vT[kX
szText db 'Hello,world!',0 F{;{o^Pv
;代码段 X4z6#S58
.code XoZPz
start: GiH<