“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 /V@9!
<^8&2wAkJ
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 o\;cXuh
i@p0Jnh|
以下是用不同语言写成的Hello World程序的几个例子: NvqIYW
Ada wz=c#}0dB
with Ada.Text_Io; use Ada.Text_Io; -3On^Wj]
procedure Hello is Zw<\^1
begin Dq G m
Put_Line ("Hello, world!"); ^J-\s_)"
end Hello; vhOX1'
(TJ )Y7E
~y.t amNW
汇编语言 0<C]9[l
p`-Oz]
x86 CPU,DOS,TASM VuWBWb?0Q
MODEL SMALL (B:+md\Q
IDEAL E\Et,l#|LY
STACK 100H ~ '/Yp8(
p,K]`pt=
DATASEG Ri mz~}+
HW DB 'Hello, world!$' \&Zp/;n
L6=`x a,
CODESEG $\A=J
MOV AX, @data A,;V|jv9
MOV DS, AX ]n9gnE
MOV DX, OFFSET HW r?j2%M\
MOV AH, 09H VW/ICX~"d
INT 21H >j$y@"+
MOV AX, 4C00H GLE/ 1
INT 21H he\ pW5p
END |b'}.(/3i
f5ttQ&@FF
N0_@=uE
x86 CPU,GNU/Linux,NASM 9H#;i]t &
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). }@H(z
;Enter this into "hello.asm" then type: 'BOMFp7c
;"nasm -f elf hello.asm" {|D7H=f
;"ld hello.o -o hello" sm?V%NX&
;"./hello" =dM'n}@U
h1AZ+9
section .data ;data section declaration 3F ]30
msg db 'Hello World!',0AH Yw_^]:~
len equ $-msg ;string length dn}'B%
`ZhS=ezgr
section .text ;code section declaration f5o##ia7:
global _start ;entry point (start of execution) &6q67
_start: mov edx,len ;string length dlJc~|
mov ecx,msg ;string start &cHA xker
mov ebx,1 ;file handle: stdout sRKoM
mov eax,4 ;sys_write {
d |lN:B
int 80h ;kernel system call 0n-S%e5
!l5&