“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 <=;#I_E#E
QKW;r
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 3z$9jN/<u
"M.\Z9BCt
以下是用不同语言写成的Hello World程序的几个例子: 'l,ym~R
Ada B5'-v%YO+
with Ada.Text_Io; use Ada.Text_Io; LF\4>(C2g
procedure Hello is F91'5D,u0
begin tOx)t$ix
Put_Line ("Hello, world!"); |E/r64T
end Hello; `w@8i[2J
L;d(|7BVv
5;{Q >n
汇编语言 b}DxD1*nsI
H+UA
x86 CPU,DOS,TASM -%8*>%
MODEL SMALL ^m^4LDt
IDEAL 9V5}%4k%+
STACK 100H i7hWBd4wK
qx,>j4yw
DATASEG j9FG)0
HW DB 'Hello, world!$' ?7Kl)p3
I"TFj$Pg
CODESEG F Xbf7G)H
MOV AX, @data F@</Ev
MOV DS, AX .EJo9s'
MOV DX, OFFSET HW DbRq,T
MOV AH, 09H '6Lw<#It
INT 21H ] B
ZSW
MOV AX, 4C00H \.m"u14[b
INT 21H 6_KO6O7g
END {9>LF
p%;n4*b2
9"T&P_
x86 CPU,GNU/Linux,NASM
_}4l4
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). !Z f<
j
;Enter this into "hello.asm" then type: J]|Zh
;"nasm -f elf hello.asm" oC"1{ybyl
;"ld hello.o -o hello" :m~R<BQ"
;"./hello" [wHGt?R
8_yhV{
section .data ;data section declaration 2$G,pT1J
msg db 'Hello World!',0AH h B@M5Mc$
len equ $-msg ;string length b#ih=qE
;Mzy>*#$Q
section .text ;code section declaration tGq0f"}'J
global _start ;entry point (start of execution) pP JhF8Dt
_start: mov edx,len ;string length h+,Eu7\88
mov ecx,msg ;string start %kB84dE
mov ebx,1 ;file handle: stdout z"[}Sk
mov eax,4 ;sys_write l_ Eeus
int 80h ;kernel system call (MfPu8j
O7&