“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 P
y!$r
^JMO POm
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 <Toy8-kj
OB4nE}NO
以下是用不同语言写成的Hello World程序的几个例子: /e;E+
Ada "$#<+H>O
with Ada.Text_Io; use Ada.Text_Io; A4{p(MS5
procedure Hello is 91\Sb:>
begin &V(;zy4(R
Put_Line ("Hello, world!"); #ZyY(S1.
end Hello; Zg&o][T
j"r7M|Z+V
!nDiAjj
汇编语言 !O 0{ .k
],-(YPiAD
x86 CPU,DOS,TASM `lcQ
Yd<,4
MODEL SMALL ,(3oAj\
IDEAL 2DNB?,uP,'
STACK 100H gp<XTLJ@>
p#0L@!,
DATASEG ('z:XW96
HW DB 'Hello, world!$' `$t|O&z
po@Agyg5
CODESEG 3|Y2BAd
MOV AX, @data 0dW*].Gi:
MOV DS, AX -, uT8'
MOV DX, OFFSET HW 'm^]X3y*
MOV AH, 09H {YK7';_E*
INT 21H +z|@K=d#|
MOV AX, 4C00H qM18Ji*
INT 21H #b9V&/ln
END ;_S
DW
yu}yON
hem>@Bp'V
x86 CPU,GNU/Linux,NASM n{I1ZlEeh
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). ,L=lg,lH^
;Enter this into "hello.asm" then type: : "^/?Sd
;"nasm -f elf hello.asm" B|K^:LUk9
;"ld hello.o -o hello" Mx Dqp;
;"./hello" DX_?-jw})f
VA5f+c/ %
section .data ;data section declaration v^dQ%+}7>
msg db 'Hello World!',0AH 1hY%ZsjC
len equ $-msg ;string length &~:+2
d7G
DIYH<
section .text ;code section declaration Z+Cjg#+
global _start ;entry point (start of execution) _BoYyJQH
_start: mov edx,len ;string length _<%YLv
mov ecx,msg ;string start /'a\$G"%6
mov ebx,1 ;file handle: stdout ` >loleI
mov eax,4 ;sys_write cD t|v~
int 80h ;kernel system call gsYQ"/S9
k$|g)[RE
mov ebx,0 ;return value b!<)x}-t>
mov eax,1 ;sys_exit ?c<uN~fC=
int 80h ;kernel system call SUDvKP
fTt\@"V
&NX7
x86 CPU,Windows,MASM32 Van=dzG
.386 N~ajrv}kd
.model flat,stdcall 'Q"Mu
option casemap:none O7oq1JI]Y
;Include 文件定义 uD\rmO{
include windows.inc ++ZP
X'|
include user32.inc mu2|%$C;$
includelib user32.lib w7c0jIf{
include kernel32.inc P@5}}vwS
includelib kernel32.lib ! u@JH`
;数据段 ZypK''&oc
.data \M;cF"e-S
szCaption db 'A MessageBox!',0 E/<n"'0ek
szText db 'Hello,world!',0 \]0#jI/:
;代码段 OX7a72z
.code WmOu#5*;
start: GX=U6n>
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK ITy/h]0
invoke ExitProcess,NULL ?pWda<&
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> N/eus"O;
end start " {X0&
\D1@UyE
`!xI!Y\
AWK hka%!W5
BEGIN { print "Hello, world!" } Wuk!\<T{
$Wu|4]o>9
.kTOG'K\e
BASIC ;ojJXH~$}
传统版BASIC(例如GWBASIC): 8)>4ZNXz
;9<?~S
10 PRINT "Hello, world!" ,$Cr9R&/
20 END <'4 8mip
YU XxQ|
或在提示符输入: x*p'm[Tdtm
N2 t`
?"Hello, world!":END l.(|&