“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 x#mZSSd
:z;}:+7n
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 D$sG1*@s-
b4_"dg~gK
以下是用不同语言写成的Hello World程序的几个例子: Q?Au.q],
Ada }]-SAM
with Ada.Text_Io; use Ada.Text_Io; j Hd <*
procedure Hello is ,n')3r
begin fO!S^<9,-
Put_Line ("Hello, world!"); /ae]v+
end Hello; Vrz6<c-'B
A+JM* eB
Ov
vM)?^#
汇编语言 Z19d Ted33
bLx70$
x86 CPU,DOS,TASM yPKDn.1
MODEL SMALL 3@k;"pFa<
IDEAL kNX(@f
STACK 100H V^qZ~US
8]DN]\\o
DATASEG 97H2hYw9l
HW DB 'Hello, world!$' |51z&dG
R/H?/
CODESEG b";w\H
MOV AX, @data u8Ul +u
MOV DS, AX .x__X3P>\
MOV DX, OFFSET HW d2w;d&2S
MOV AH, 09H N=)
E$h
INT 21H *+p9u 1B5
MOV AX, 4C00H %@<}z|.4
INT 21H M5C}*c9
END k~ZwHx(%S
v=b`kCH}
H6<\7W89y
x86 CPU,GNU/Linux,NASM _7SOl.5ZE
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). 6gS<h\h0
;Enter this into "hello.asm" then type: 8aw'Q?
;"nasm -f elf hello.asm" r4}:t$
;"ld hello.o -o hello" YoD1\a|
;"./hello" U8?%Dq%i
YaTJKgi"0
section .data ;data section declaration LC5NB{b\%>
msg db 'Hello World!',0AH M9MfO*
len equ $-msg ;string length W
M/pP?||
dMsX}=EI<
section .text ;code section declaration =K#D^c~
global _start ;entry point (start of execution) S#{e@ C
_start: mov edx,len ;string length 48]1"h%*qB
mov ecx,msg ;string start |F36^
mov ebx,1 ;file handle: stdout Mn(:qQo^&`
mov eax,4 ;sys_write 4/S% eZB
int 80h ;kernel system call wU_e/+0h
WpX)[au
mov ebx,0 ;return value [Q,E(
s
mov eax,1 ;sys_exit <`EZ^S L;
int 80h ;kernel system call 4oLrCQZ\
(3C6'Wt
e7/ b@
x86 CPU,Windows,MASM32 x|l[fdm5
.386 tk4~ 8
.model flat,stdcall I%(`2rD8G
option casemap:none }<w/2<