“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 _I{&5V~z
2: pq|eiF
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 DLS-WL
dmlh;Z
以下是用不同语言写成的Hello World程序的几个例子: 6ap,XFRMh
Ada 0)ST_2Ci
with Ada.Text_Io; use Ada.Text_Io; +Ya-h~7;g#
procedure Hello is
C&e
begin %Pa-fee
Put_Line ("Hello, world!"); `9K'I-hv<8
end Hello; _tjFb_}Q
5R"b1
CdZ;ZR
汇编语言 W:rzfO.`Z
DT 9i<kl
x86 CPU,DOS,TASM ACyQsmqm:
MODEL SMALL r{%NMj
IDEAL !+>yCy$~_
STACK 100H -vjjcyTt
JAB]kNvI
DATASEG }=f}@JlFB
HW DB 'Hello, world!$' <V6#)^Or
JH)&Ca>S
CODESEG r4D66tF
MOV AX, @data _R5^4 -Qe
MOV DS, AX ;F5B)&/B
MOV DX, OFFSET HW ,\=u(Y\I[
MOV AH, 09H 1>1|>%
INT 21H {'!D2y.7g
MOV AX, 4C00H L~mL9[( ,
INT 21H u'32nf?
END VwC,+B
jC\R8_
^<% w'*gR
x86 CPU,GNU/Linux,NASM uxh4nyE
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). k*M{?4
;Enter this into "hello.asm" then type: YRYrR|I
;"nasm -f elf hello.asm" Ok:@F/ v
;"ld hello.o -o hello" DJn>. Gd
;"./hello" V 9<[v?.\
7#g C(&\A
section .data ;data section declaration F`u{'w:Hv
msg db 'Hello World!',0AH yv'rJI~ Ps
len equ $-msg ;string length UBU(@T(
3ZB;-F5v
section .text ;code section declaration H/, tE0ZV
global _start ;entry point (start of execution) b-O4IDIT
_start: mov edx,len ;string length 3c9[FZ@ya
mov ecx,msg ;string start j|[s?YJl
mov ebx,1 ;file handle: stdout zJ9,iJyuD
mov eax,4 ;sys_write [ B (lJz
int 80h ;kernel system call ]a:kP,
a:;*"p[R
mov ebx,0 ;return value Y7{|EI+@
mov eax,1 ;sys_exit vfy-;R(
int 80h ;kernel system call oOUVU}H
rg'? ?rq
Pc(2'r@#
x86 CPU,Windows,MASM32 3BSeZ:j7
.386 s-C.+9
.model flat,stdcall M?\)&2f[Z
option casemap:none F~DG:x~
;Include 文件定义 Ffhbs D
include windows.inc uj:w^t ][
include user32.inc olYSr .Q`
includelib user32.lib Vy/g;ZPU1
include kernel32.inc +s S*EvF
includelib kernel32.lib K^w9@&