“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 h iK}&
4UK>Vzn
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 C0/G1\
='@k>Ka+
以下是用不同语言写成的Hello World程序的几个例子: rq1zvuUx
Ada oFT1d
with Ada.Text_Io; use Ada.Text_Io; DyA1zwp}
procedure Hello is p*Yx1er1
begin 4n1 g@A=y
Put_Line ("Hello, world!"); t;u)_C,bmP
end Hello; b
`bg`}x
+;=>&XR0m
KHGUR(\Rd6
汇编语言 )*Wz5x
LI^D\
x86 CPU,DOS,TASM j?g#8L;W\w
MODEL SMALL QL2 `X2
IDEAL HrMbp
STACK 100H EQX<<x"
"-j96
KD
DATASEG R<%{I)
HW DB 'Hello, world!$' ^:,wk7
ooP{Q r
CODESEG o 9(x\g
MOV AX, @data j8]M}Q$
MOV DS, AX P>$+XrTE
MOV DX, OFFSET HW Om_ "X6
MOV AH, 09H hh2&FI
INT 21H ]z| 2
MOV AX, 4C00H [nlq(DGJhp
INT 21H 4W<[& )7
END }5}>B *
F8M};&=*1r
EMdU4YnE"
x86 CPU,GNU/Linux,NASM . ~a~(|
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). h
cu\c+ A
;Enter this into "hello.asm" then type: ?6L8#"=
;"nasm -f elf hello.asm" 9e}%2,
;"ld hello.o -o hello" ! |z!e>0
;"./hello" `LKf$cx(A
;%cW[*Dw
section .data ;data section declaration *P&lAyt6
msg db 'Hello World!',0AH g>`D!n::n
len equ $-msg ;string length T)Q_dF.N
5@
Hg 4.
section .text ;code section declaration 9xE_Awlc85
global _start ;entry point (start of execution) D9hq$?
_start: mov edx,len ;string length .q!i
+0
mov ecx,msg ;string start H+@?K6{h
mov ebx,1 ;file handle: stdout ~:|V,1
mov eax,4 ;sys_write |cC&,8O:{
int 80h ;kernel system call Og?GYe^_
NRspi_&4J
mov ebx,0 ;return value Y{Lxo])e
mov eax,1 ;sys_exit @gmo;8?k
int 80h ;kernel system call `-K[$V
NL2D,
Q]/{6:C
x86 CPU,Windows,MASM32 W7{^/s5r
.386 B|{E[]iK
.model flat,stdcall VW;E14
option casemap:none M a3}w-=;
;Include 文件定义 H6Gs&y