“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 U1Q:= yD
?xA:@:l/
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 \1d( 9jR
~W*FCG#E
以下是用不同语言写成的Hello World程序的几个例子: =pr`'
Ada "7U4'Y:E
with Ada.Text_Io; use Ada.Text_Io; 1f%1*L0>@
procedure Hello is &)2i[X
begin 0mpX)S
Put_Line ("Hello, world!"); #akpXdXs
end Hello; "33Fv9C#bK
0Vj4+2?L5;
D{!6Y*d6&s
汇编语言 phQUD
EJj.1/]|r
x86 CPU,DOS,TASM 5]~'_V
MODEL SMALL -M~8{buxv
IDEAL ,aOl_o -&
STACK 100H czA5n
R$v[!A+:'
DATASEG >~#yu&*D
HW DB 'Hello, world!$' B`YTl~4
LU
\i0|i|
CODESEG #r$cyV!k
MOV AX, @data ks&*O!h
MOV DS, AX 2$9odD<r
MOV DX, OFFSET HW Ac96
[
MOV AH, 09H )(A]Ln4
INT 21H q6@Lp^f
MOV AX, 4C00H v5/~-uRL%
INT 21H @_-hk|Nl@
END $>G8_q
yZ
@"\Z!
m];]7uB5=
x86 CPU,GNU/Linux,NASM ,ly\Ka?zO
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). =FlDb
5t{
;Enter this into "hello.asm" then type: Z|%_&M
;"nasm -f elf hello.asm" r~E=4oB7
;"ld hello.o -o hello" XywE1}3
;"./hello" #[,IsEpDO1
%]Fd[pzF
section .data ;data section declaration I*o()
msg db 'Hello World!',0AH z[LNf.)}
len equ $-msg ;string length 5rwu!Y;7*
-]L6=
section .text ;code section declaration v;BV@E0}x
global _start ;entry point (start of execution) Ld\R:{M"
_start: mov edx,len ;string length aL*&r~`&e'
mov ecx,msg ;string start . kQkC:~9
mov ebx,1 ;file handle: stdout Bu#E9hJFvA
mov eax,4 ;sys_write U GD2
int 80h ;kernel system call >d*iD
^b/ Z)3
mov ebx,0 ;return value ?iPC*
mov eax,1 ;sys_exit I*%-cA%l
int 80h ;kernel system call G(Lzf(
o#;b
vmi+_]
x86 CPU,Windows,MASM32 bT\1>
.386 ]}*R| 1
.model flat,stdcall IW>T}@
|
option casemap:none ;t'5},(FP
;Include 文件定义 , qA(\[
include windows.inc ^.1)};i
include user32.inc ={_C&57N1
includelib user32.lib !\"EFVH
include kernel32.inc qUh2hz:
includelib kernel32.lib -jW.TT h]
;数据段 7[w,:9& }
.data TBs|r#
szCaption db 'A MessageBox!',0 4 kn|^
szText db 'Hello,world!',0 ]"J~:{, d
;代码段 rk&IlAE
.code N6>(;ugJ1-
start: f) zn TJL
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK N|1M1EBOu>
invoke ExitProcess,NULL QU4h8}$
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> #J@[Wd
end start s2teym,uG
fo5iJz"Z
ZNJ@F<