“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 prBLNZp
)vr@:PE
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 j)1y v.
@u3`lhUcT
以下是用不同语言写成的Hello World程序的几个例子: ^6 6!f 5^W
Ada ;`9f<d#\
with Ada.Text_Io; use Ada.Text_Io; 1C[9}}
procedure Hello is &dtk&P{
begin <G"cgN#]
Put_Line ("Hello, world!"); L\yVE
J9x
end Hello; y>{:[L9*
:fRXLe1=
XGlt^<`
汇编语言 F c[KIG3@
$o"nTl
x86 CPU,DOS,TASM k<1yv$/mW
MODEL SMALL QWmE:F[M~
IDEAL O9gq <d
STACK 100H ;rh.6D l
A 'qe2]
DATASEG VFT@Ic#]
HW DB 'Hello, world!$' ?-??>& z
.@dC]$2=
CODESEG 61\u{@o$
MOV AX, @data f*ZU a
MOV DS, AX WlL(NrVA@@
MOV DX, OFFSET HW [^>XRBSm
MOV AH, 09H fBO/0uW
INT 21H r4.6W[|d
MOV AX, 4C00H [ X*p
[
INT 21H Re%[t9F&
END -luQbGcT3
gW,[X(
a+h$u
x86 CPU,GNU/Linux,NASM 5'lVh/
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). J )1
;Enter this into "hello.asm" then type: dzcF15H1
;"nasm -f elf hello.asm" ;yH>A ;,K%
;"ld hello.o -o hello" 5s7BUT
;"./hello" CB7dr&>
N'^>pSc4W|
section .data ;data section declaration dQut8>0&
msg db 'Hello World!',0AH '1<Z"InU
len equ $-msg ;string length {N(qS'N
+vc +9E.?9
section .text ;code section declaration OhF55,[
global _start ;entry point (start of execution) F<4rn
_start: mov edx,len ;string length ;w{<1NH2+.
mov ecx,msg ;string start "EW8ll7r
mov ebx,1 ;file handle: stdout M,Gy.ivz
mov eax,4 ;sys_write [|\6AIoS
int 80h ;kernel system call #J5BHY~
[hJ1]RW8
mov ebx,0 ;return value [X(m[u '%
mov eax,1 ;sys_exit OY*y<