“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 ]E-3/r$_cO
pbEWnx_
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 p5$}h,7
{f\wIZ-K A
以下是用不同语言写成的Hello World程序的几个例子: %VFoK-a
Ada \c<;!vkZ04
with Ada.Text_Io; use Ada.Text_Io; =3c?W&:
procedure Hello is xhbN=L
begin v@|<.
Put_Line ("Hello, world!"); -Uy)=]Zae
end Hello; ~CT]&({
EYn?YiVFU
vRH^en
汇编语言 {j9TzR
|YsR;=6wT
x86 CPU,DOS,TASM eM_;rM Cr}
MODEL SMALL {N>ju
IDEAL cFw-JM<
STACK 100H z`IW[N7Z
_$96y]Bpi
DATASEG L&DjNu`!9
HW DB 'Hello, world!$' w.w{L=p:<"
7H)$NG<U$
CODESEG !Z tqh Xr
MOV AX, @data E+i*u
MOV DS, AX g}v](Q
MOV DX, OFFSET HW :c~SH/qS
MOV AH, 09H zawu(3?~)5
INT 21H ":$4/b6
MOV AX, 4C00H n!4\w>h
INT 21H ]B,tCBt
END V*b/N
.p!
DVQ"a
O3@DU#N&s
x86 CPU,GNU/Linux,NASM fr/EkL1Dl
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). w2.]
3QAZ
;Enter this into "hello.asm" then type: ?OFa
Q
;"nasm -f elf hello.asm" > O?WRCB
;"ld hello.o -o hello" YK6LJv}
;"./hello" n7fhc*}:`
a2B71 RT~
section .data ;data section declaration g8N"-j&@
msg db 'Hello World!',0AH &N^~=y^`C'
len equ $-msg ;string length E xhih^[_
U0_)J1Yp
section .text ;code section declaration YbU8 xq
global _start ;entry point (start of execution) rNq*z,
_start: mov edx,len ;string length Mpojabsh
mov ecx,msg ;string start 6^gp
/{
mov ebx,1 ;file handle: stdout LZn'+{\`
mov eax,4 ;sys_write ri{*\LV*@
int 80h ;kernel system call )k=KLQ\b
'nq=xi@RC
mov ebx,0 ;return value i]r(VKX
mov eax,1 ;sys_exit f256;3n
int 80h ;kernel system call }_'5Vb_
!:|*!
ie6c/5
x86 CPU,Windows,MASM32 %XGm\p
.386 Q]K` p(
.model flat,stdcall G x[ZHpy;
option casemap:none pJ]
Ix *M
;Include 文件定义 zvV&Hks-
include windows.inc GM6,LzH
include user32.inc BX?DI-o^h
includelib user32.lib L[Vk 6e
include kernel32.inc a&_