“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 wV;qc3
iS^IqS
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 "$tP>PO{<
L;0ZB=3n
以下是用不同语言写成的Hello World程序的几个例子: X|F([,o
Ada FXPw 5
with Ada.Text_Io; use Ada.Text_Io; $b/oiy!=|3
procedure Hello is DM%4V|F"
begin PZRm.vC)k
Put_Line ("Hello, world!"); b:nHcxDU<
end Hello; i#
1:DiF
)0P>o]fWI
.h2K$(/
汇编语言 WX}"Pj/6
F~dq7AS
x86 CPU,DOS,TASM ~)#JwY
MODEL SMALL +`==US34
IDEAL 6t|FuTC
STACK 100H 2rq)U+
*1}'ZEaJ
DATASEG Z4/rqU
HW DB 'Hello, world!$' 40}8EP k)
yD+)!q"
CODESEG [e+"G <>
MOV AX, @data ?+S& `%?
MOV DS, AX HPGi5rU
MOV DX, OFFSET HW XTD_q
MOV AH, 09H )x-iru
A:
INT 21H BOLG#}sm
MOV AX, 4C00H 9i8D_[
INT 21H D84`#Xbi
END O>zM(I+p
wY2#xD
WVp7H
x86 CPU,GNU/Linux,NASM [g_Cg=J
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). :cmfy6h]
;Enter this into "hello.asm" then type: O1Gd_wDC/i
;"nasm -f elf hello.asm" SB1\SNB
;"ld hello.o -o hello" mKwhd} V
;"./hello" 9qe6hF/29
*K6 V$_{S
section .data ;data section declaration X 5LI
msg db 'Hello World!',0AH z./M^7v?
len equ $-msg ;string length uuzDu]Gwu
\Clz#k8l1
section .text ;code section declaration Y%b
5{1
global _start ;entry point (start of execution) ?]081l7cd
_start: mov edx,len ;string length CE>RAerY
mov ecx,msg ;string start 1o7
pMp=
mov ebx,1 ;file handle: stdout #e0tT+
mov eax,4 ;sys_write 93yJAao9
int 80h ;kernel system call +.Kmpw4
q79)nhC F
mov ebx,0 ;return value hSc$Sa8
mov eax,1 ;sys_exit b<qv
/t)$
int 80h ;kernel system call MEbx{XC
W
xyQA:3s
yf!
x86 CPU,Windows,MASM32 @4m_\]Wy
.386
AA9OElCa
.model flat,stdcall :2?J#/o
option casemap:none <L@0w8i`
;Include 文件定义 d{@X-4k:
include windows.inc YBN.
waL
include user32.inc pO$`(+q[
includelib user32.lib 0s:MEX6w|
include kernel32.inc P$Y<
g/s4
includelib kernel32.lib [6Uc?Bi
;数据段 kIV/o
.data 3ryIXC\v
szCaption db 'A MessageBox!',0 W?!(/`J]
szText db 'Hello,world!',0 W{l+_a{/9
;代码段 e
=Vu;
.code C_?L$3 U0
start: '|<