“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 ^\B4]'+^j
I(R%j]LX&
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 71[?AmxV
~3gazTe9
以下是用不同语言写成的Hello World程序的几个例子: l@GJcCufE
Ada hE=xS:6
with Ada.Text_Io; use Ada.Text_Io; #p*uk
procedure Hello is L)U*dY
begin ER9{D$
Put_Line ("Hello, world!"); =Y|( }92
end Hello; Q+Q"J U
$<)]~**K
Ve"(}z
汇编语言 @hA`f4^
$6UU58>n
x86 CPU,DOS,TASM ; ,sNRES3
MODEL SMALL m0^ "fMV
IDEAL CQ6I4k
STACK 100H H0"'jd
Wm-$l
DATASEG %D#&RS
HW DB 'Hello, world!$' ["&{^
}Em{?Hqy
CODESEG aG;F=e
MOV AX, @data H:hM(m0?q
MOV DS, AX Dmi.@.
MOV DX, OFFSET HW -V4{tIQY
MOV AH, 09H qVfn(rZ
INT 21H !Q~>)$Cf^
MOV AX, 4C00H b6k_u9m^E
INT 21H @R`6jS_gK
END |0}Xb|+
.+XK>jl+
^(+q1O'
x86 CPU,GNU/Linux,NASM cOdRb=?9
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). b1#C,UWK
;Enter this into "hello.asm" then type: rAHP5dx:
;"nasm -f elf hello.asm" p({@t=L3g
;"ld hello.o -o hello" sdO8;v>
;"./hello" p: z][I
#Swc>jYc
section .data ;data section declaration 0!YVRit\N
msg db 'Hello World!',0AH Hl%Og$q3
len equ $-msg ;string length fh)eL<I
E-Xz
section .text ;code section declaration 9[VYd '
global _start ;entry point (start of execution) ;0m J4G
_start: mov edx,len ;string length NX%1L!
#
mov ecx,msg ;string start 6|q"lS*$S
mov ebx,1 ;file handle: stdout q
j21#q
.
mov eax,4 ;sys_write Peph..8 Z
int 80h ;kernel system call y>t:flD*
&uE )Vr4 R
mov ebx,0 ;return value N`IXSE
mov eax,1 ;sys_exit ~),%w*L
int 80h ;kernel system call /y{fDCC
?,riwDI 2
;0kAm
Vy
x86 CPU,Windows,MASM32 V*s\ ~h)
.386 #FAW@6QG
.model flat,stdcall 6P>Y2xV:
option casemap:none (Q||5
;Include 文件定义 ejR$N!LL
include windows.inc +-;v+{
include user32.inc qh6b;ae\x
includelib user32.lib r1IvA^X
include kernel32.inc *jc
>?)k
includelib kernel32.lib NVkYm+J#
;数据段 6<\dQ+~
.data rMJ@oc
szCaption db 'A MessageBox!',0 ~.^:?yCA
szText db 'Hello,world!',0 m=E/um[D
;代码段 :kI[Pf!z
.code X4:84
start: jbe:"Stw
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK JE:LA+ (
invoke ExitProcess,NULL |*J;X<Vm
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> GjW(&p$&
end start <`Fl Igo
S6bYd`
<