“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 2,bLEhu
_`LQnRp(
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 tLc9-
rV6SN.
以下是用不同语言写成的Hello World程序的几个例子: n)6mfoe
Ada W^sH|2g
with Ada.Text_Io; use Ada.Text_Io; '"~ 2xiin
procedure Hello is U|!L{+F
begin 4qe!+!#$
Put_Line ("Hello, world!"); \&Bvh4Q
end Hello; stcbM
d|Q_Z@;JF
530Z>q
汇编语言 !W?6,i -]
%"{jNC?
x86 CPU,DOS,TASM [t.x cO
MODEL SMALL ?Gr2@,jlD
IDEAL 6Q}WX[| tQ
STACK 100H k6|wiSyu
= U)e_q
DATASEG 5$;#=WAY
HW DB 'Hello, world!$' NJ ];Ck
f.X<Mo
CODESEG e/*T,ZJ
MOV AX, @data gxf{/EjH
MOV DS, AX %V2A}78
MOV DX, OFFSET HW hErO.ad1o
MOV AH, 09H t.YY?5l
INT 21H `:y {
MOV AX, 4C00H (I7s[
INT 21H p#DJow
END ,4`=gKn
IJz=SV
}_[Bp
x86 CPU,GNU/Linux,NASM XA4miQn&
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). CUG3C
;Enter this into "hello.asm" then type: -w#*~Q{'*
;"nasm -f elf hello.asm" 8n`O{8:fi
;"ld hello.o -o hello" ;(1Xb
;"./hello" fO'"UI
|^!
section .data ;data section declaration GR ^d/
msg db 'Hello World!',0AH \cKY{(E
len equ $-msg ;string length R-\a3q
FvTc{"w /
section .text ;code section declaration
W!.vP~ >
global _start ;entry point (start of execution) x.ZW%P1
_start: mov edx,len ;string length $lYy `OuC
mov ecx,msg ;string start qo^PS
mov ebx,1 ;file handle: stdout @}[yC['
mov eax,4 ;sys_write /6@iRswa
int 80h ;kernel system call pZUXXX
gLGu#6YVu
mov ebx,0 ;return value (s?Rbd
mov eax,1 ;sys_exit 8kA2.pIk
int 80h ;kernel system call ZT'VF~
9S8>"w^R
0%f}w0]:
x86 CPU,Windows,MASM32 XNd%3rm,
.386 $wq[W,'#L
.model flat,stdcall Q#a<T4l
option casemap:none :l/?cV;
;Include 文件定义 g(`m#&P>G
include windows.inc vC1D}=Fp
include user32.inc 07FS|>DM'Z
includelib user32.lib 0! 6n
include kernel32.inc aUVJ\;V
includelib kernel32.lib Rx\.x? &
;数据段 7%x
3o#&
.data Dx1 w I
szCaption db 'A MessageBox!',0 F
)|0U~
szText db 'Hello,world!',0 P_{jZ}y(
;代码段 npD`9ff
.code &R7N^*He
start: +&j