“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 Ro2V-6/
Lbz/M_G
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 Zb1GR5MB`k
}XBF#BN
以下是用不同语言写成的Hello World程序的几个例子: a8T9=KY^
Ada qLLrR,:
with Ada.Text_Io; use Ada.Text_Io; /Kli C\
procedure Hello is R5=J :o
begin G>vK$W$f N
Put_Line ("Hello, world!"); rogy`mh\r2
end Hello; G]aey>)
a%`Yz"<lQ
85&7WAco"B
汇编语言 NHyUHFY
g$GGo[_0
x86 CPU,DOS,TASM QoxYzln
MODEL SMALL i.6 b%
IDEAL %^lD
STACK 100H H1U$ApD
[&99#7B
DATASEG ~2rQ80_
HW DB 'Hello, world!$' >|%3j,<U
kNWTM%u9
CODESEG "G>d8GbIh
MOV AX, @data Lm}.+.O~d
MOV DS, AX m@kLZimD
MOV DX, OFFSET HW ((]i}s0S
MOV AH, 09H 7#j.yf4
INT 21H &Pme4IHtm
MOV AX, 4C00H o
A2oX
INT 21H Y({
R\W|
END ~ `}),aA
:u9'ZHkZ
5T.U=_ag
x86 CPU,GNU/Linux,NASM 5XX)8gAo
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). ktfm
;Enter this into "hello.asm" then type: EoJ\Jk
;"nasm -f elf hello.asm" BJ5MCb.w
;"ld hello.o -o hello" P x Q] $w
;"./hello" ~-vCY
F&!vtlV)
section .data ;data section declaration >#:SJ?)`T
msg db 'Hello World!',0AH L~/,;PHN
len equ $-msg ;string length &=)O:Jfa
%bTuE' `b
section .text ;code section declaration `Ns@W?
global _start ;entry point (start of execution) (8m_ GfT
_start: mov edx,len ;string length R/"f
mov ecx,msg ;string start AJB
NM
mov ebx,1 ;file handle: stdout mhrF9&s
mov eax,4 ;sys_write >z%YKdq
int 80h ;kernel system call #b*4v&<
&C