“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 <uk1?Qg
[;.`,/
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 (j"(
deeU@x`f<
以下是用不同语言写成的Hello World程序的几个例子: X$\i{p9jw
Ada $1zvgep
with Ada.Text_Io; use Ada.Text_Io; XJ+6FT/qss
procedure Hello is g3sUl&K
begin d~_`M0+
Put_Line ("Hello, world!"); \cJ-Dd
end Hello; H{c?lT
b*mKei
iH2n.M
"
汇编语言 L]hXpt
]G}B 0u3
x86 CPU,DOS,TASM !lmWb-v%36
MODEL SMALL 9>#:/g/
IDEAL $7Mtt.d6
STACK 100H ixh47M
o:dR5v
DATASEG 5;TuVU.8Q
HW DB 'Hello, world!$' v !Kw<
fp|
xg{HQQ|TC
CODESEG ]AS"z<
MOV AX, @data OAZ#|U
MOV DS, AX 7W9d6i)
MOV DX, OFFSET HW \hP=-J [~C
MOV AH, 09H kK~IwA
INT 21H 7C?.L70ZY
MOV AX, 4C00H +f;CyMEp
INT 21H E}Xka1 Bn
END 2o[IHO]
hvt@XZT
bv
dR"G
x86 CPU,GNU/Linux,NASM ;}.Kb
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). 1(GHCxA8G
;Enter this into "hello.asm" then type: dow^*{fqZ
;"nasm -f elf hello.asm" f.pkQe(
;"ld hello.o -o hello" )06iV
;"./hello" fd8#Ng"1
>^"BEG9i:
section .data ;data section declaration ;<G<1+
msg db 'Hello World!',0AH x@cN3O
len equ $-msg ;string length H.O(*Q=
mf|pNiQ,
section .text ;code section declaration I(n* _bFq
global _start ;entry point (start of execution) ?Zyok]s
_start: mov edx,len ;string length OalP1Gy
mov ecx,msg ;string start vh>{_
#
mov ebx,1 ;file handle: stdout 'CS.p!Z\
mov eax,4 ;sys_write /k"hH\Pp
int 80h ;kernel system call T"E( F
2Q$\KRE
mov ebx,0 ;return value WY)^1Gb$ux
mov eax,1 ;sys_exit VKLU0*2R
int 80h ;kernel system call i&@,5/'-_O
Inuc(_I
f@:CyB GQ
x86 CPU,Windows,MASM32 [7"}=9
.386 }w!ps{*
.model flat,stdcall ~%q7Vmk9
option casemap:none hD 46@
;Include 文件定义 Bx X$5u
include windows.inc Q.(51]'
include user32.inc ?'~;Q)
includelib user32.lib #cEq_[yI
include kernel32.inc zw:/!MS
includelib kernel32.lib U
%:c],Fk
;数据段 ^)cM&Bxt%
.data l6B.6
'4)w
szCaption db 'A MessageBox!',0 &R\XUxI
szText db 'Hello,world!',0 .{N\<