“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 n:Dr< q.
#jg3Ku;Y
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 eO{2rV45O
rKl
以下是用不同语言写成的Hello World程序的几个例子: q\~D:z$+CO
Ada gV'=uz v
with Ada.Text_Io; use Ada.Text_Io; 9Dyy&$s
procedure Hello is 1z@ ncqe
begin Cio(Ptt:
Put_Line ("Hello, world!"); lvUWs
end Hello; W=,]#Z+M;
ffaMF~+
/EL3Tt
汇编语言 Ihl]"76q/
pz.fZV
x86 CPU,DOS,TASM ,rhNXx
MODEL SMALL \JNWL yw
IDEAL 3:b5#c?R-
STACK 100H R5<:3tk=X
1#2L9Bi
DATASEG BIT<J5>
HW DB 'Hello, world!$' B<,AI7
"h&[6-0'
CODESEG -?ebkHe
MOV AX, @data =z}M(<G
MOV DS, AX iF"kR]ZL
MOV DX, OFFSET HW m\K1Ex
MOV AH, 09H WX$AOnEv
INT 21H P>7PO~E.
MOV AX, 4C00H Q?dzro4C
INT 21H Ystd[
END ) =|8%IrB
q)tNH/
DF"*[]^[
x86 CPU,GNU/Linux,NASM XZ|\|(6Cc
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). kX:8sbZ##4
;Enter this into "hello.asm" then type: $XFFNE`%
;"nasm -f elf hello.asm" /? Bu^KX
;"ld hello.o -o hello" g<i>252>
;"./hello" w.Go]dpK
[Y6ZcO/-i
section .data ;data section declaration |PLWF[+t8
msg db 'Hello World!',0AH ES[]A&tf
len equ $-msg ;string length
e:6mz\J
n5?7iU&JIo
section .text ;code section declaration J8DKia|h(
global _start ;entry point (start of execution) !]P=v`B.
_start: mov edx,len ;string length RIF*9= ,S
mov ecx,msg ;string start vH]2t.\
mov ebx,1 ;file handle: stdout e`%<D[-
mov eax,4 ;sys_write 0y/P
int 80h ;kernel system call 8*(|uX
sH Hu<[psM
mov ebx,0 ;return value . Kk'N
mov eax,1 ;sys_exit "%+9p6/
int 80h ;kernel system call ;x4yidb6
M V~3~h8
'zYx4&s
x86 CPU,Windows,MASM32 D(M^%z2N
.386 'tq4-11xB
.model flat,stdcall '6Yx03t
option casemap:none v?S3G-r
;Include 文件定义 dxF)) Z
include windows.inc 6/L34VH
include user32.inc oo!JAv}~
includelib user32.lib FJ O-p
include kernel32.inc S{qsq\X
includelib kernel32.lib qjLFgsd
;数据段 ?rgtbiSW-
.data \v([,tiW%
szCaption db 'A MessageBox!',0 f15n ~d
szText db 'Hello,world!',0 p}-B>v
;代码段 Y/G~P,9
.code F2mW<REg{
start: g}*F"k4j
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK "A&