“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 EtN,
P(k*SB|D
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 s_NY#MPz[
X1.-C@o
以下是用不同语言写成的Hello World程序的几个例子: KqntOo}
y)
Ada n~ad#iN
with Ada.Text_Io; use Ada.Text_Io; `~)?OTzU#
procedure Hello is ?DUim1KG
begin HZRFE[ 9nb
Put_Line ("Hello, world!"); L?N&kzA
end Hello; aj;x:UqpJ
oLKliA=q
M^:JhX{
汇编语言 !\R5/-_UU
F,~BhKkbV
x86 CPU,DOS,TASM
JHa1lj
MODEL SMALL L.'61ZU
IDEAL w gS'/
STACK 100H zFm`e:td
uE')<fVX(
DATASEG k37?NoT
HW DB 'Hello, world!$' p]RQ-0
&SbdX
CODESEG Q/]~`S
MOV AX, @data cmXbkM
MOV DS, AX VU,G.eLW
MOV DX, OFFSET HW #wIWh^^ Zy
MOV AH, 09H u>lt}0
INT 21H 3 k/E$wOj
MOV AX, 4C00H \[3~*eX6
INT 21H h6D4CT
END )mm0PJF~q
_{k*JT2
>B0AJW/u
x86 CPU,GNU/Linux,NASM P".}Y[GD
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). vK)'3%
;Enter this into "hello.asm" then type: Zo&i0%S\E
;"nasm -f elf hello.asm" i-v: %
;"ld hello.o -o hello" n<8WjrK
;"./hello" =|E
"
;99oJD,
section .data ;data section declaration gW~T{+f
msg db 'Hello World!',0AH cgrSd99.
len equ $-msg ;string length hE(R[hc
g}<jn'@{
section .text ;code section declaration pmB
{b
global _start ;entry point (start of execution)
aO<7a
6
_start: mov edx,len ;string length hc
q&`Gun
mov ecx,msg ;string start %oa@2qJ^
mov ebx,1 ;file handle: stdout GO"|^W
mov eax,4 ;sys_write bfz7t!A)A
int 80h ;kernel system call ~
q-Z-MA
C7{VByxJ
mov ebx,0 ;return value SDC|>e9i
mov eax,1 ;sys_exit t7-]OY7%w_
int 80h ;kernel system call jI\@<6O
_ZhQY,
5]Rbzg2t
x86 CPU,Windows,MASM32 akyMW7'3V<
.386 bp9RF
d{
.model flat,stdcall >p-UQc
option casemap:none 6a,8t
;Include 文件定义 n%F _3`
include windows.inc ,K,st+s|
include user32.inc s>6h]H
includelib user32.lib HN5661;8
include kernel32.inc ;"Gy5
includelib kernel32.lib O
ixqou
;数据段 {4 Yxh8
.data Bz } nP9
szCaption db 'A MessageBox!',0 G7&TMg7i
szText db 'Hello,world!',0 DK?aFSf\
;代码段 (o|bst][S
.code BZW03e8|
start: phu,&DS!
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK 8HKv_vl
invoke ExitProcess,NULL !rRBy3&
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> z9S
(<