“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 }@NT#hD
V8IEfU
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 Q0-}!5`E1$
$+Zj)V(
以下是用不同语言写成的Hello World程序的几个例子: N83g=[
Ada -A;4""
with Ada.Text_Io; use Ada.Text_Io; 7?EC
kuSv
procedure Hello is YRs32vVz
begin g@B,0JRh
Put_Line ("Hello, world!"); oK{H
<79
end Hello; <O30X
!QuK
n;0x\Q|S
qFg"!w
汇编语言 wwh)B92Y5
e=w.7DSE
x86 CPU,DOS,TASM H/BU2s a
MODEL SMALL b8TwV_&|X
IDEAL dT4e[4l
STACK 100H =~F.7wq*^
iTg7@%
DATASEG )\|Bghui
HW DB 'Hello, world!$' u|uPvbM
`6`oLu\l
CODESEG fk
MOV AX, @data e+7x &-+
MOV DS, AX {Wh7>*p{3
MOV DX, OFFSET HW X/-u$c
MOV AH, 09H /8tF7Mmr
INT 21H A3c&VT6Q
MOV AX, 4C00H ;,Q6AS!
INT 21H (N` x
END d@0&
Q2 @Ugt$
? bnhx
x86 CPU,GNU/Linux,NASM 4>$weu^
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). M}*#{UV2
;Enter this into "hello.asm" then type: K_t!P
;"nasm -f elf hello.asm" /ng+IC3
;"ld hello.o -o hello" gyAKjLqqpi
;"./hello" FQGh+.U
_/%,ZoZ2
section .data ;data section declaration SwVdo|%.?
msg db 'Hello World!',0AH +/Q?<*[
len equ $-msg ;string length E#A}J:
#(Ah>y
section .text ;code section declaration F^)SQ%xx
global _start ;entry point (start of execution) t ]yD95|
_start: mov edx,len ;string length T{Rhn V1
mov ecx,msg ;string start c
DO<z
mov ebx,1 ;file handle: stdout dLIZ)16&
mov eax,4 ;sys_write ] f~mR_E
int 80h ;kernel system call _aLml9f
W
=Zc
Vywz;+
mov ebx,0 ;return value QwL'5ws{q
mov eax,1 ;sys_exit )i{B:w\ ^
int 80h ;kernel system call =(U&?1 R4
>7^i>si
[r"`rBw
x86 CPU,Windows,MASM32 4_B1qN
.386 BO3%p
.model flat,stdcall Lavm
option casemap:none Q'n]+%YN
;Include 文件定义 u"*Wo'3I|
include windows.inc XexslzI
include user32.inc "G,$Sqi@
includelib user32.lib MEZc/Ru-[
include kernel32.inc =9@t6
includelib kernel32.lib 7)y9%-}
;数据段 (hv>vfY@
.data 5gnmRd
szCaption db 'A MessageBox!',0 >84:1`
szText db 'Hello,world!',0 qqR8E&Y{
;代码段 fR6.:7&
.code BvA09lK
start: XK7$Xbd
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK _[_mmf1;:'
invoke ExitProcess,NULL @g~hYc
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> c5e
wG
end start ;[>g(W+
hRWRXC9
J&bhR9sF
AWK }|W n6X
BEGIN { print "Hello, world!" } I||4.YT
d#*n@@V4
4Ev#`i3~
BASIC 6rD
Oa~<