“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 Q\Gq|e*
fa&-. *
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 K7e4_ZGI
ExSO|g]%
以下是用不同语言写成的Hello World程序的几个例子: R8-^RvG
Ada 6 CC &Z>
with Ada.Text_Io; use Ada.Text_Io; X 6lH|R
procedure Hello is T*I?9d{k
begin 1`LXz3uBe
Put_Line ("Hello, world!"); RGIoI]_
end Hello; Z?NEO>h7
wQ+dJ3b$
16X@^j_
汇编语言 Z~6[ Z
<w>/^|]#
x86 CPU,DOS,TASM ~P-*}q2J
MODEL SMALL pilh@#_h
IDEAL IN7<@OS7
STACK 100H >Z Ke
m,>
DATASEG pO~c<d}b
HW DB 'Hello, world!$' pi@Xkw
JI|6B
CODESEG |<`.fOxJP
MOV AX, @data U@Tj B
MOV DS, AX ~%ozgzr^
MOV DX, OFFSET HW 8BXqZVm.
MOV AH, 09H D);'pKl
INT 21H [9mL $;M
W
MOV AX, 4C00H G",.,Px
INT 21H `nJu?5
END :XV}
c(+d
MS<SAD>w
?Qqd "=k4
x86 CPU,GNU/Linux,NASM 0nW F
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). .G>t72DpU
;Enter this into "hello.asm" then type: Y7U&Q:5'
;"nasm -f elf hello.asm" ~^N]yb
;"ld hello.o -o hello" %G?K@5?j?
;"./hello" XidxNPz0^
pKJK9@Ad
section .data ;data section declaration
0=6/yc
msg db 'Hello World!',0AH $v}<'
len equ $-msg ;string length {UH9i'y:t
$T }Tz7(
section .text ;code section declaration UQd6/mD`e
global _start ;entry point (start of execution)
N<JHjq
_start: mov edx,len ;string length xi'<y
mov ecx,msg ;string start %85Icg
mov ebx,1 ;file handle: stdout !rTmR@e$/
mov eax,4 ;sys_write . p^xS6e{
int 80h ;kernel system call ])y{BlZ
8SnS~._9
mov ebx,0 ;return value
L2-^!'
mov eax,1 ;sys_exit *+lsZ8'^C
int 80h ;kernel system call ilEi")b=
&K:' #[3V
O|v
(58A
x86 CPU,Windows,MASM32 tLX,+P2|
.386 ;R[&pDx
.model flat,stdcall 5n:71$6[
option casemap:none PDw{R]V+
;Include 文件定义 RTd^ImV
include windows.inc EIX\O6*
include user32.inc @?2n]n6
includelib user32.lib _|n=cC4Qu
include kernel32.inc [}""@?
includelib kernel32.lib TGWdyIk
;数据段 d$1#<