“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 U_~~PCi
4kM<L}J#
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 Txh;r.1e
6uyf
以下是用不同语言写成的Hello World程序的几个例子: qSd
$$L^
Ada z|2liQrf+
with Ada.Text_Io; use Ada.Text_Io; `jHGNi
procedure Hello is -*A'6%`
begin 9wC; m :
Put_Line ("Hello, world!"); ||4Dtg
K
end Hello; 4Rn i7qH
1rEP)66N
C0%%@
2+
汇编语言 ;k8}D*?8
Kf4z*5Veqr
x86 CPU,DOS,TASM DbN'b(+
MODEL SMALL f+V':qz
IDEAL 7'S]
STACK 100H +*V;
f,
8(}sZ)6
DATASEG J (h>
HW DB 'Hello, world!$' hqPn~Tq
n1Jz49[r
CODESEG : [y(<TLw
MOV AX, @data ? la_ +;m
MOV DS, AX ho1F8TG=
MOV DX, OFFSET HW !UTJ) &
MOV AH, 09H l5FQ!>IM
INT 21H 6{'6_4;Fv(
MOV AX, 4C00H tOw
0(-:iq
INT 21H MlFvDy
END D;]%
jvQ"cs$.
)^TQedF
x86 CPU,GNU/Linux,NASM 9f\8oJQ
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). O 0#Jl8
;Enter this into "hello.asm" then type: AX+d? M
;"nasm -f elf hello.asm" __j8jEV
;"ld hello.o -o hello" i7V~LO:gq
;"./hello" BvF_9
n^N]iw{G
section .data ;data section declaration }=a4uCE
msg db 'Hello World!',0AH M;qL)vf
len equ $-msg ;string length d&`j8O
KU,w9<~i(
section .text ;code section declaration \aIy68rH,
global _start ;entry point (start of execution) <q\)
o_tH
_start: mov edx,len ;string length Ib!rf:
mov ecx,msg ;string start x[UO1% _o-
mov ebx,1 ;file handle: stdout K"7;Y#1g
mov eax,4 ;sys_write )1Nnn
int 80h ;kernel system call Y)}%SP>,
on?/tHys
mov ebx,0 ;return value `aL|qyrq#
mov eax,1 ;sys_exit 1 ],,
Ar5
int 80h ;kernel system call aa8Qslm
~qxXou,J
{yMA7W7]
x86 CPU,Windows,MASM32 JWHt|zBg
.386 J"/z?!)IB
.model flat,stdcall NxO^VUD
option casemap:none d~-p;i
;Include 文件定义 8Ql'(5|T
include windows.inc ?7)(qnbe"
include user32.inc ^85n9a?8
includelib user32.lib Ir"Q%>K0f
include kernel32.inc '<< ~wt
includelib kernel32.lib y[6&46r7D
;数据段 lk1Gs{(qhH
.data zK4
8vo
szCaption db 'A MessageBox!',0 bDBO+qA
szText db 'Hello,world!',0 !]+Z%ed`%
;代码段 LG{inhbp
.code )kKmgtj
start: kN|5
J
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK fGf-fh;s
invoke ExitProcess,NULL nVn|$ "r
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ~X<cG=p~u
end start zX [r
F] ?@X
m+2`"1IE[
AWK RE
$3| z
BEGIN { print "Hello, world!" } Qy5Os?9"
76A>^Bs\/
Nv?-*&