“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 Xsb.xxK.
x5rm
2C
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 Gyi0SM6v5&
&kWT<*;J)
以下是用不同语言写成的Hello World程序的几个例子: M9VAs~&S
Ada OHngpe4
with Ada.Text_Io; use Ada.Text_Io; .gRb'
procedure Hello is 9XS>;<"2
begin `tH F}
Put_Line ("Hello, world!"); =VWH8w.3
end Hello; YyYp-0#
l'!_km0{d
%dmQmO,
汇编语言 M!VW/vdywL
<dS I"C<
x86 CPU,DOS,TASM ij?]fXf:)y
MODEL SMALL xw~oR|`U
IDEAL _iqaKYT$
STACK 100H A5}N[|z
n]l3
)u
DATASEG ;L],i<F
HW DB 'Hello, world!$' Y?oeP^V'u
2I=4l
CODESEG ms&5Bq+9
MOV AX, @data KxJDAP
MOV DS, AX LsMq&a-j2
MOV DX, OFFSET HW WT 5 2
MOV AH, 09H tC+11M
INT 21H rP(;^8l"
MOV AX, 4C00H 6lr<{k7Nw
INT 21H 6: R1jF*eG
END ^#h ;bX#
Fkqw#s(T
Aba%QQQ
x86 CPU,GNU/Linux,NASM z+_d* \
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). "[_gRe*2
;Enter this into "hello.asm" then type: !a%_A^t7
;"nasm -f elf hello.asm" JsX}PVuL
;"ld hello.o -o hello" )ZZ6 (O
;"./hello" K[V#Pj9
@9]TjZd
section .data ;data section declaration mX@xV*
msg db 'Hello World!',0AH *L<<S=g$2
len equ $-msg ;string length FYg{IKg
77]Fp(uI
section .text ;code section declaration 6%c]{eTd9
global _start ;entry point (start of execution) VB+_ kR6Zv
_start: mov edx,len ;string length ?%>S5,f_
mov ecx,msg ;string start dHn,;Vv^6
mov ebx,1 ;file handle: stdout R C!~eJG!
mov eax,4 ;sys_write ]>+ teG:4
int 80h ;kernel system call V1,4M _Z
xiC.M6/
mov ebx,0 ;return value cGg~+R2P
mov eax,1 ;sys_exit 6D4u?P,
int 80h ;kernel system call `Z@qWB<
w/ID yQ
Jd|E
4h~(
x86 CPU,Windows,MASM32 '_n$xfH
.386 0e'@Xo2e
.model flat,stdcall [GW;RjPE
option casemap:none A22'qgKm@
;Include 文件定义 dP/1E6*m
include windows.inc ~NK|q5(I
include user32.inc 8(:O5#
includelib user32.lib z_$F)*PL
include kernel32.inc .k5&C/jv
includelib kernel32.lib S]c&