“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 4KR`
p=E#!cn3
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 -Q
JP J.
k0ai#3iJ
以下是用不同语言写成的Hello World程序的几个例子: =H;'.!77Hx
Ada *)
T"-}F
with Ada.Text_Io; use Ada.Text_Io; v@q&B|0
procedure Hello is -LUZ7,!/>o
begin |3T2}oh rr
Put_Line ("Hello, world!"); [+R_3'aK
end Hello; >1Hv c7DP
8zlvzp
Z}>F
V~4
汇编语言
_(8#
!5?_)
x86 CPU,DOS,TASM _Z9d.-
MODEL SMALL .s,04xW\
IDEAL _xm<zy{`S
STACK 100H }d>.Nj#zh
QKq4kAaJ!
DATASEG p}pd&ut1
HW DB 'Hello, world!$' wuYak"KX
&QW&K
CODESEG Q3&DA1b`
MOV AX, @data #Y=b7|l
MOV DS, AX U!uJ )mm
MOV DX, OFFSET HW E0fMFG^P
MOV AH, 09H esBv,b?*
INT 21H !u8IZpf
MOV AX, 4C00H Xa#.GrH6
INT 21H AH/o-$C&
END UQ;2g\([
ty"L&$bf
!m9hL>5vR
x86 CPU,GNU/Linux,NASM rEC
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). ;|?_C8
;Enter this into "hello.asm" then type: @{_X@Wv4iV
;"nasm -f elf hello.asm" 4;AQ12<[1
;"ld hello.o -o hello" :Rv+Bm
;"./hello" D]}~` SO
h^Yh~84T
section .data ;data section declaration p3mZw lO
msg db 'Hello World!',0AH {6RA~
len equ $-msg ;string length _a& Z$2O
*n&Sd~Mg
section .text ;code section declaration PI`Y%! P
global _start ;entry point (start of execution) 9@q!~ur
_start: mov edx,len ;string length _b-g^#L%
mov ecx,msg ;string start Qb>("j~Z
mov ebx,1 ;file handle: stdout )uo".n|n~B
mov eax,4 ;sys_write 3%GsTq2o
int 80h ;kernel system call $|J+
XxdD)I
mov ebx,0 ;return value 6Y,&