“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 *k [J6
gL3iw!7
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 Pbn!KX~F~
W:`#% :C
以下是用不同语言写成的Hello World程序的几个例子: @gY\;[#.
Ada tY+$$GSQj
with Ada.Text_Io; use Ada.Text_Io; vXv;1T
procedure Hello is [AS}RV
begin dJ
~Zr)>
Put_Line ("Hello, world!"); ~#PLAP3-
end Hello; kn"q:aD
!'G~k+
C <B<o[:H
汇编语言 $,fy$
Qk,S
Xg7|JS!
x86 CPU,DOS,TASM 6N~q`;p0
MODEL SMALL Sk}{E@
IDEAL MS3=~*+
STACK 100H ,.tfWN%t\
9Uf j
DATASEG 9\JQ7$B
HW DB 'Hello, world!$' SA;#aj}rV
Y?K{(szo ?
CODESEG d2N:^vvvR
MOV AX, @data }TB(7bbd;
MOV DS, AX n,$z>
MOV DX, OFFSET HW !H@0MQ7
MOV AH, 09H g}x(hF
INT 21H 2%B'3>a
MOV AX, 4C00H -WJ?:?'
INT 21H F$V/K&&W
END Y?d9l
7f{=w,
U
+4))/`DA
x86 CPU,GNU/Linux,NASM ;# uZhd
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). 5!X1G8h)uy
;Enter this into "hello.asm" then type: O|kOI?f
;"nasm -f elf hello.asm" 9?<{_'
;"ld hello.o -o hello" @?
c2)0
;"./hello" *L4`$@l8
)h{ ]k=
section .data ;data section declaration QDx$==Fo
msg db 'Hello World!',0AH )e|=mtp
len equ $-msg ;string length Q~{H@D`<
k8AW6oO/i
section .text ;code section declaration n'1'!J;Q
global _start ;entry point (start of execution) PcT?<HU
_start: mov edx,len ;string length %]2,&
mov ecx,msg ;string start fHRMu:q
mov ebx,1 ;file handle: stdout {)8>jxQN
mov eax,4 ;sys_write Az;t"
int 80h ;kernel system call @p 6<Lw_E
kM8{Cw
mov ebx,0 ;return value v\tEVhm
mov eax,1 ;sys_exit PwB1]p=
int 80h ;kernel system call sEJC-$
Gf EX>
T .FI'wy
x86 CPU,Windows,MASM32 U1nw-Q+
.386 "VG+1r+]4
.model flat,stdcall %Dg0fL
option casemap:none @Fp_^5
;Include 文件定义 EJ@p-}I!
include windows.inc 4d b(<h
include user32.inc *z*uEcitW
includelib user32.lib ~Wo)?q8UY,
include kernel32.inc Y_woKc*
includelib kernel32.lib G3G#ep~)vC
;数据段 F8:vDv
.data Zwz&