“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 b#@xg L*D
N/F_,>E
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 x"Ll/E)\v]
Pt85q?- >
以下是用不同语言写成的Hello World程序的几个例子: _xAru9=n^
Ada kL zjK]4 *
with Ada.Text_Io; use Ada.Text_Io; xp1/@Pw?
procedure Hello is KGDN)@D
begin O^\:J2I(
Put_Line ("Hello, world!"); <N<0 ?GQ
end Hello; W!HjO;
(ORbhjl
.=YV
汇编语言 g5#LoGc
+FNGRL
x86 CPU,DOS,TASM ;uAh)|;S#
MODEL SMALL [GbrKq(
IDEAL /
xv5we~
STACK 100H ,JI] Eij^
#8XmOJ"W3k
DATASEG 1$DcE>
HW DB 'Hello, world!$' oC"
[rn
\X\< +KU
CODESEG a)W|gx6Y
MOV AX, @data Y
22Ai
MOV DS, AX ~hq\XQX
MOV DX, OFFSET HW *
4J!@w
MOV AH, 09H f-#:3k*7S
INT 21H PI L)(%X
MOV AX, 4C00H vFHeGq70j
INT 21H TAh'u|{u2
END H,c1&hb/w
)-X8RRw'
_886>^b@
x86 CPU,GNU/Linux,NASM 1VYH:uGuAU
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). $MvKwQ/
;Enter this into "hello.asm" then type: D0 k ,8|
;"nasm -f elf hello.asm" nN$.^!;&
;"ld hello.o -o hello" }s?3
;"./hello" @ *Jbp
*[cCY!+Qy
section .data ;data section declaration $|Ol?s
msg db 'Hello World!',0AH ;e_us!Sn
len equ $-msg ;string length ?IeBo8
[&~x5l
8\C
section .text ;code section declaration PJ:!O?KVq
global _start ;entry point (start of execution) j+'ua=T3
_start: mov edx,len ;string length O:I]v@
mov ecx,msg ;string start i5(qJ/u
mov ebx,1 ;file handle: stdout n]vCvmt
mov eax,4 ;sys_write [3=Y 9P:
int 80h ;kernel system call #:=c)[G8
IJ+}
mov ebx,0 ;return value 9Znc|<
mov eax,1 ;sys_exit b`%u}^B {
int 80h ;kernel system call <- sr&
\6GNKeN
V%[t'uh
x86 CPU,Windows,MASM32 {_W8Qm`.
.386 U}HSL5v
.model flat,stdcall 5f_x.~ymA
option casemap:none {
#B/4
;Include 文件定义 prM)t8SE
include windows.inc \aPH_sf,
include user32.inc w8S
pt
includelib user32.lib ,y"vf^BE.
include kernel32.inc +EA ")T<l
includelib kernel32.lib F%zMhX'AG
;数据段 >l-u{([B
.data IA}vN3
szCaption db 'A MessageBox!',0 yLqhj7
szText db 'Hello,world!',0 @rqmDpU
;代码段 #Qg)4[pMJ
.code hc$m1lLn
start: U`N?<zm<oO
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK vC&0UNe$
invoke ExitProcess,NULL 1r4NP
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> **-rPonM[
end start UazK0{t<f
RJ3uu NK7
8|=
c3Z
AWK =KO]w9+\
BEGIN { print "Hello, world!" } @fA|y
`B&