“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 P(f0R8BE
xsD($_
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 ax<?GjpM
o6uJyCO
以下是用不同语言写成的Hello World程序的几个例子: oaIi2=Tf
Ada ):[7E(F=
with Ada.Text_Io; use Ada.Text_Io; o{y9r{~A
procedure Hello is :0Rx#%u}#
begin E4M@WNPx
Put_Line ("Hello, world!"); t&AFUt\c
end Hello; V T\F]Oa#
o%IA}e7PAa
{y_98N
汇编语言 )!P)U(*v
:qd`zG3
x86 CPU,DOS,TASM JPoN&BTCj
MODEL SMALL ~=uWD&5B4
IDEAL ,Vt/(x-
STACK 100H 1ng!G 7g
?j"KV_
DATASEG ?B2] -+Y
HW DB 'Hello, world!$' E2Q[ZoVS
!1$])VQWI
CODESEG 4b98KsYg
MOV AX, @data $\X[@E S0
MOV DS, AX sT}.v*
MOV DX, OFFSET HW rustMs2p
MOV AH, 09H Z$/xy"
INT 21H o!kbK#k
MOV AX, 4C00H ~f$|HP}
INT 21H t.xxSU5~%
END AP'*Nh@Ik(
I|^;B8[
B><d9d
x86 CPU,GNU/Linux,NASM iKX-myCz
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). ]&lY%"U$i
;Enter this into "hello.asm" then type: _./Sk|C
;"nasm -f elf hello.asm" 1;Ou7T9w
;"ld hello.o -o hello" wea-zN
;"./hello" b4[bL2J$h1
H9YW
section .data ;data section declaration Y^$X*U/q%U
msg db 'Hello World!',0AH %C|n9*
len equ $-msg ;string length "@iK'
c^
:bwjJ}F
section .text ;code section declaration y1dDO2mA
global _start ;entry point (start of execution) n*[XR`r}
_start: mov edx,len ;string length ;:\<gVi:
mov ecx,msg ;string start
<G|(|E1
mov ebx,1 ;file handle: stdout fF7bBE)L/|
mov eax,4 ;sys_write `d5%.N
int 80h ;kernel system call RI(DXWM|h
9]f!'d!5
mov ebx,0 ;return value "_-Po^u=r
mov eax,1 ;sys_exit Azl&m