“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 HFx"fT
^YJ^+:D(
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 ^RyTK|SQ
o`8+#+@f7
以下是用不同语言写成的Hello World程序的几个例子: NDa|.,
Ada (F
'
with Ada.Text_Io; use Ada.Text_Io; 8~Hs3\Hp
procedure Hello is )>M@hIV5>
begin '-]BSU
Put_Line ("Hello, world!"); [`-O-?=
end Hello; 8!%"/*P$
gL}Y5U+s
>fj$wOq
汇编语言 &|\}\+0Z
9"lW"lG!
x86 CPU,DOS,TASM i[\u-TF
MODEL SMALL x(zZqOed
IDEAL pL/.JzB
STACK 100H {ZM2WFpE
!@Vp Bl
DATASEG p+sPCF
HW DB 'Hello, world!$' {i}Q}OgYq
ftU5A@(T
CODESEG Hr*Pi3 dSI
MOV AX, @data YB3=ij!K
MOV DS, AX
<d&)|W
MOV DX, OFFSET HW W>wi;Gf#
MOV AH, 09H 2-c0/?_4
INT 21H .d!*<`S|
MOV AX, 4C00H 0:+uw`
%
INT 21H z slEUTj)
END 1HWJxV"
j4SGA#;v
UR2)e{RXg
x86 CPU,GNU/Linux,NASM A^@ <+?
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). yIf}b
;Enter this into "hello.asm" then type: LqsJHG
;"nasm -f elf hello.asm" ]bE?n.NwZ
;"ld hello.o -o hello" !gew;Jz
;"./hello" b-zX3R;
/cen#pb
section .data ;data section declaration to|9)\
msg db 'Hello World!',0AH RZh)0S>J
len equ $-msg ;string length NP'DuzC
4"(zi5`e
section .text ;code section declaration Dj.+5f'
global _start ;entry point (start of execution) "s<lLgi
_start: mov edx,len ;string length []3}(8yxGb
mov ecx,msg ;string start Jv.R?1;8i
mov ebx,1 ;file handle: stdout UBHQzc+,
mov eax,4 ;sys_write fO(S+}
int 80h ;kernel system call <slq1
dTQvz9 C
mov ebx,0 ;return value A":b_!sW
mov eax,1 ;sys_exit U*:'/.
int 80h ;kernel system call }Y ];ccT
tRBK1h
l'%R^
x86 CPU,Windows,MASM32 ^|;4/=bbs
.386 R./ 6Q1
.model flat,stdcall {1DYXKe
option casemap:none 10IPq#Jj
;Include 文件定义 c+/C7C o
include windows.inc Iw7r}G
include user32.inc I8;[DP9
includelib user32.lib i O|,,;_
include kernel32.inc rg/vxTl
includelib kernel32.lib j$oZIV7
;数据段 emPm^M5/K
.data oz-I/g3go
szCaption db 'A MessageBox!',0 R0<