“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 oUltr
KGP2,U6
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 8ru@ 8|r
F3';oyy
以下是用不同语言写成的Hello World程序的几个例子: rAP+nh ans
Ada N|1J@"H
with Ada.Text_Io; use Ada.Text_Io;
78qf
procedure Hello is 1;.}u=8
begin 0IQu6
X
Put_Line ("Hello, world!"); 5jx{O${u
end Hello; OK3B6T5w=
wT*`Od8w
IK~ur\3
汇编语言 C[gSiL
n$#^gzU4
x86 CPU,DOS,TASM % fA0XRM
MODEL SMALL HAGWA2wQ
IDEAL 5'+g'9
STACK 100H Og30&a!~F
xv4nYm9
DATASEG Y*wbFL6`
HW DB 'Hello, world!$' i,;Q
}Z0)FU+
CODESEG -cY/M~
MOV AX, @data 0A5xG&
MOV DS, AX "=4=Q\0PT
MOV DX, OFFSET HW 'DntZK
MOV AH, 09H 0vQkm<
INT 21H "]zq<LmX
MOV AX, 4C00H @OwU[\6fc}
INT 21H ,!sAr;Rk`
END 2HQHC]
[>C^ 0\Z~
BN#^
/a-
x86 CPU,GNU/Linux,NASM mI0|lp 1$
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). d{ OY
;Enter this into "hello.asm" then type: Z;WqKIM#
;"nasm -f elf hello.asm" G=yQYsC$
;"ld hello.o -o hello" Y*w<~m
;"./hello" -pg7>vO q
P3lNns3
section .data ;data section declaration tC|5;'m.2
msg db 'Hello World!',0AH Fo~C,@/Qt
len equ $-msg ;string length 2<u vz<B
Z( xn-
section .text ;code section declaration V :d/;~
global _start ;entry point (start of execution) hDmVv;M:
_start: mov edx,len ;string length ='soSnT
mov ecx,msg ;string start YdC:P#
Nf
mov ebx,1 ;file handle: stdout J0o U5d=3
mov eax,4 ;sys_write _ogT(uYyr
int 80h ;kernel system call e[Q(OV5(R
^+,mxV'8!
mov ebx,0 ;return value #i)h0ML/e
mov eax,1 ;sys_exit M{O2O(
int 80h ;kernel system call 5
0~L(<
s2w.V
O
'|WMt g
x86 CPU,Windows,MASM32 #-e3m/>
.386 8&`s wu&
.model flat,stdcall j}0*`[c
option casemap:none <`6-J `.
;Include 文件定义 joM98H@
include windows.inc K;[V`)d'
include user32.inc fFSW\4JD=
includelib user32.lib Jc{zi^)(EN
include kernel32.inc 8)R)h/E>
includelib kernel32.lib (">!vz
;数据段 z %mM#X
.data xA&