“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 /{&tY:;m
_ jsK}- \
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 #)nSr
aeD ;5VV
以下是用不同语言写成的Hello World程序的几个例子: sfNE68I2
Ada \ZkA>oO".
with Ada.Text_Io; use Ada.Text_Io; ;XBI{CW
procedure Hello is ]iUxp+
begin h5^Z2:#
Put_Line ("Hello, world!"); ,LnII
end Hello; w9bbMx
;<ZLcTL
\RG8{G,
汇编语言 bJX)$G
J|qZ+A[z
x86 CPU,DOS,TASM ax<?GjpM
MODEL SMALL LA}Syt\F
IDEAL 9@Jtaq>jf
STACK 100H Hhcpp7cr'
rp;b" q
DATASEG }F#okU
HW DB 'Hello, world!$' ,Pdf,2
uo@n(>}EL
CODESEG '2 PF
MOV AX, @data fR(d
MOV DS, AX uc){+'[
MOV DX, OFFSET HW 3R.W>U
MOV AH, 09H U`2e{>'4t
INT 21H T[g[&K1Y
MOV AX, 4C00H 9[.8cg*
INT 21H ,)vDeU
END _I:/ZF5
A\HxDIU
`ojoOB^L
x86 CPU,GNU/Linux,NASM u=`L)
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). \nPEyw,U
;Enter this into "hello.asm" then type: (KDD e}f
;"nasm -f elf hello.asm" J1C3&t}
;"ld hello.o -o hello" gaZu;t2u
;"./hello" -;^j:L{
)-a'{W/t
section .data ;data section declaration &E.^jR~*
msg db 'Hello World!',0AH ewctkI$,5
len equ $-msg ;string length +JjW_Rl?=V
n[lJLm^(_C
section .text ;code section declaration ^\4h<M
global _start ;entry point (start of execution) {y=j?lD
_start: mov edx,len ;string length K/IWH[
mov ecx,msg ;string start wk5s)%V
mov ebx,1 ;file handle: stdout ^hZ0IM
mov eax,4 ;sys_write )b)-ZS7
int 80h ;kernel system call xc=b
|:A
n>BkTaI
mov ebx,0 ;return value MkfBuW;)
mov eax,1 ;sys_exit Nn!+,;ut
int 80h ;kernel system call W*Zkc:{eB
old(i:2
: y%d
x86 CPU,Windows,MASM32 g/CSGIIT
.386 S[PE$tYT#t
.model flat,stdcall 0jy2H2
option casemap:none >0ow7Uw;
;Include 文件定义 VY
| _dk
include windows.inc t*Sa@$p
include user32.inc I ?gSG*m
includelib user32.lib (nf~x
include kernel32.inc Z2qW\E^_r
includelib kernel32.lib /5(Yy}
;数据段 Azl&m