“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 Z&^vEQ
-,
+o*BP
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 }<G
ae5
*c#DB{N
以下是用不同语言写成的Hello World程序的几个例子: b#7nt ?`7p
Ada vT5GUO{5
with Ada.Text_Io; use Ada.Text_Io; ky !ZJR
procedure Hello is xDe^>(,"
begin 9{u/|,rq1
Put_Line ("Hello, world!"); Wda?$3!^q
end Hello; 9@t&jznt<
oxFd@WV5
e[k\VYj[
汇编语言 eZ)
|m
T72Li"00
x86 CPU,DOS,TASM |%4nU#GoB
MODEL SMALL ?o V.SG'
IDEAL n}NUe`E_h
STACK 100H 1mgw0QO
R?:K\
DATASEG $I`,nN
HW DB 'Hello, world!$' U-?r>K2
>a@1y8B
CODESEG "j%Gr:a
MOV AX, @data x^3K=l;N
MOV DS, AX J{Ij
MOV DX, OFFSET HW <mLU-'c@
MOV AH, 09H F\+9u$=
INT 21H \ bNDeA&l
MOV AX, 4C00H z@[n?t!7k
INT 21H Xj?LU7
END [HXd|,~_j-
-XECYwTh
#\~m}O,
x86 CPU,GNU/Linux,NASM g3n>}\xG>
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). 5'Mw{`
;Enter this into "hello.asm" then type: .O5|d+S
;"nasm -f elf hello.asm" sC.cMZ e
;"ld hello.o -o hello" OwC{ Ad{
;"./hello" ),;h
9MRe?
section .data ;data section declaration Wi)N/^;n
msg db 'Hello World!',0AH N}bZdE9F
len equ $-msg ;string length PClwGO8'&
gO~>*q &
section .text ;code section declaration n-9X<t|*?a
global _start ;entry point (start of execution) Ft2ZZ<As
_start: mov edx,len ;string length <D nv=)Rq
mov ecx,msg ;string start D5T0o"A
mov ebx,1 ;file handle: stdout S r7EcT-
mov eax,4 ;sys_write %'F[(VB
int 80h ;kernel system call z<"\I60Fe
M>Ws}Y
mov ebx,0 ;return value $>~4RXC
mov eax,1 ;sys_exit h7\EN
int 80h ;kernel system call i#lO{ ]
~xZ)btf
AQBr{^inH|
x86 CPU,Windows,MASM32 5o~AUo{
.386 jK=-L#hz
.model flat,stdcall l$p"%5]_
option casemap:none 2L2)``*
;Include 文件定义 bU(fH^
include windows.inc BYDOTy/%nJ
include user32.inc }WkR-5N
includelib user32.lib pzBd(d^*
include kernel32.inc v/Ei0}e6~
includelib kernel32.lib Qgv-QcI{
;数据段 0j~C6vp
.data /?8rj3
szCaption db 'A MessageBox!',0 `Axn
szText db 'Hello,world!',0 Jqi^Z*PuX
;代码段 T*C]:=)
.code [[:wSAO>6'
start: 2}R)0][W
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK +l$BUX
invoke ExitProcess,NULL 3m`y?Dd
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> yX8$LOjE
end start Y_&