“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 *X^C+F
x,|fblQz
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 6OqF-nso[E
umCmxmr&
以下是用不同语言写成的Hello World程序的几个例子: D
!{e
Ada _9q byhS7
with Ada.Text_Io; use Ada.Text_Io; uh%
J
procedure Hello is fYpJ2y-sA
begin {ft |*
Put_Line ("Hello, world!"); | GN/{KH]
end Hello; 'p@m`)Z
N-q6_
q$"?P
汇编语言 .`(YCn?\
.1z=VLKF'
x86 CPU,DOS,TASM .zTkOkL
MODEL SMALL Fk9]u^j
IDEAL $ wDSED -
STACK 100H |*M07Hc x
9e.$x%7j
DATASEG <{@ D^L6h
HW DB 'Hello, world!$' piqh7u3~
Ya(3Z_f+VZ
CODESEG {?"X\5n0
MOV AX, @data H )CoByaj
MOV DS, AX '-cayG
MOV DX, OFFSET HW hT `&Xb
MOV AH, 09H BzV97'
INT 21H ?@kz`BY
MOV AX, 4C00H I!SIy&=W
INT 21H xM@s`s|n
END ]9c{qm}y
{fjBa,o
#
| g1Cs
x86 CPU,GNU/Linux,NASM KZa6*,,s
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). (!qfd
Qq#
;Enter this into "hello.asm" then type: C6h[L
;"nasm -f elf hello.asm" :qzhkKu
;"ld hello.o -o hello" mn*}U R
;"./hello" PZO.$'L|7
%oWG"u
section .data ;data section declaration y&bZai8WlE
msg db 'Hello World!',0AH e+:X%a4\
len equ $-msg ;string length A/"2a55
'St?nW3
section .text ;code section declaration /Ak\Q5O'3
global _start ;entry point (start of execution) <0? r#
}
_start: mov edx,len ;string length rY8(`a
mov ecx,msg ;string start Q
laoa)d#
mov ebx,1 ;file handle: stdout 4bL? V^@7
mov eax,4 ;sys_write Z^=(9:
int 80h ;kernel system call 2##mVEo.(
'Yh`B8
mov ebx,0 ;return value yu&mu