“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 Kd3EZo.
h
x
hl
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 oBWa\N
iZ2nBiQ
以下是用不同语言写成的Hello World程序的几个例子: R|!4klb
Ada N-Sjd%Z
with Ada.Text_Io; use Ada.Text_Io; 2?c%<_jPA
procedure Hello is `xFgYyiQd
begin m2to94yh
Put_Line ("Hello, world!"); gg
:{Xf*`
end Hello; "'U]4Z%q!
~P+;_
5Fa/Q>N
汇编语言 -W)8Z.
m%i!;K"{s
x86 CPU,DOS,TASM K%NgZ(x(
MODEL SMALL tQIz
IDEAL kC0^2./p
STACK 100H 1h&_Q}DM
e `IL7$
DATASEG OBZ:C!
HW DB 'Hello, world!$' SHe547X1
Q%_MO`<]$
CODESEG ROr| <
MOV AX, @data 6Vy4]jdT5
MOV DS, AX biAa&
MOV DX, OFFSET HW 6i*LP(n
MOV AH, 09H `5t
CmU
INT 21H 3aEO9v,n
MOV AX, 4C00H QZ_8r#2x
INT 21H Cq<k(TKAX
END S(hT3MAW
O|0} m
Xa&0j&AH
x86 CPU,GNU/Linux,NASM 604^~6
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). :X#'ELo|
;Enter this into "hello.asm" then type: vN`JP`IBx
;"nasm -f elf hello.asm" ddvtBAX
;"ld hello.o -o hello" rJc=&'{&)N
;"./hello" ?YhGW
hbTJXP~~?
section .data ;data section declaration RRR=R]
msg db 'Hello World!',0AH )zvjsx*e=J
len equ $-msg ;string length O}q(2[*i
oJVpJA0IA
section .text ;code section declaration t3;QF
global _start ;entry point (start of execution) ya/pn
qS
_start: mov edx,len ;string length hrTl:\
mov ecx,msg ;string start @z7$1pl}
mov ebx,1 ;file handle: stdout .jbT+hhM
mov eax,4 ;sys_write qJ<Ghd`8v
int 80h ;kernel system call ZTK)N
Oftjm
X_
mov ebx,0 ;return value 8DZ
OPA
mov eax,1 ;sys_exit n.xOu`gj
int 80h ;kernel system call jI,?*n<
q|N4d9/b
p"=8{LrO
x86 CPU,Windows,MASM32 q%8Ck)xz
.386 !_j6\r=
.model flat,stdcall yI_MYL[
option casemap:none [35>T3Ku
;Include 文件定义 'V(9ein^Q
include windows.inc xs$-^FnD
include user32.inc 5q{
-RJ
includelib user32.lib ny[\yj4F
include kernel32.inc YEhPAQNj
includelib kernel32.lib eLN[`hJ
;数据段 E#mpj~{-
.data y'U-y"7y
szCaption db 'A MessageBox!',0 dmUa\1g#
szText db 'Hello,world!',0 _&/2-3]\B
;代码段 6eAJ>9@x
.code #=aT Sw X
start: @!2vS@f
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK yo"!C?82=
invoke ExitProcess,NULL _f<#+*y
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 55vI^SSA
end start hC...tk
,(&