“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 w# e'K-=
c;^ J!e
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 {ZcZ\Q;6
dc05,Bz
以下是用不同语言写成的Hello World程序的几个例子: z)%1 i
Ada lK4+8VZ
with Ada.Text_Io; use Ada.Text_Io; 4(R2V]
procedure Hello is k mjm6
begin _a&|,ajy>
Put_Line ("Hello, world!"); E(@;p%:
end Hello; FMVmH!E
"7HB3?2>W
~laZ(Bma);
汇编语言 asg>TOW
:m d3@r']
x86 CPU,DOS,TASM Pio^5jhB6
MODEL SMALL )hug<D *h
IDEAL #*!$!c{
STACK 100H OLrD4 e
!A!\S/x4
DATASEG R%%`wmG)"
HW DB 'Hello, world!$' h uJqqC
CC\z_C*P-p
CODESEG K\b O[J
MOV AX, @data q8Dwu3D
MOV DS, AX i7rq;t<
MOV DX, OFFSET HW 9QMn%8=j
MOV AH, 09H GcnY=%L?
INT 21H ZkW@ |v
MOV AX, 4C00H g1~I*!p
INT 21H D@^ZpN8r
END uNbA>*c4M
eEQ[^i
?_aR-[XRg
x86 CPU,GNU/Linux,NASM `dP+5u!
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). *K|aK p}
;Enter this into "hello.asm" then type: D.(G 9H
;"nasm -f elf hello.asm" tWnm{mF
;"ld hello.o -o hello" ~8*oGG~s
;"./hello" YJ$ewK4E#.
>A&@W p1
section .data ;data section declaration F-^HN%
msg db 'Hello World!',0AH 1c#'5~nB
len equ $-msg ;string length G+uiZ(p>
(fa?ftK
section .text ;code section declaration Ug21d42Z4
global _start ;entry point (start of execution) $)Yo g]}
_start: mov edx,len ;string length :eW~nI.Vc
mov ecx,msg ;string start hli10p$
mov ebx,1 ;file handle: stdout
#-T.@a1X
mov eax,4 ;sys_write bZ.N7X PH
int 80h ;kernel system call +ZKhmb!
6>:~?gs
mov ebx,0 ;return value cO,V8#H
mov eax,1 ;sys_exit xV#a(>-4
int 80h ;kernel system call Hc]1mM
AxlFU~E4
GYC&P]
x86 CPU,Windows,MASM32 wkD:i 2E7
.386 (0W}e(D8
.model flat,stdcall Eap/7U1Q
option casemap:none y.p6%E_`
;Include 文件定义 -vHr1I<
include windows.inc SFk#bh
include user32.inc Jv<