“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 aFfd!a"n
a%FM)/oI|T
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 9?xD"Z
E$8D^Zt
以下是用不同语言写成的Hello World程序的几个例子: r:xbs0
7
Ada L+GVB[@3Y
with Ada.Text_Io; use Ada.Text_Io; PP1?UT=]
procedure Hello is * |dz.Tr
begin >^odV
;^
Put_Line ("Hello, world!"); =uG}pgh0
end Hello; 0UbY0sYo
p]lZ4#3
!=/wpsH
汇编语言 ;kE|Vx
Y<vHL<G
x86 CPU,DOS,TASM cM|!jnKm
MODEL SMALL Tl/!Dn
IDEAL ()\=(n!J
STACK 100H I=;.o>
8gIf
DATASEG f$2DV:wuC
HW DB 'Hello, world!$' r9\7I7z
_`Lv@T.
CODESEG 16cc9%
MOV AX, @data Qo%IZw$l
MOV DS, AX /[<1D|f%
MOV DX, OFFSET HW F4R0A6HL
MOV AH, 09H k1h>8z.Tg
INT 21H @)^|U"
MOV AX, 4C00H GJeP~
INT 21H <F%c"Rkh
END #'qDNY@ w}
7]J7'!Iz
`<oNEr+#
x86 CPU,GNU/Linux,NASM CW+] Jv]"
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). p)k5Uh"
;Enter this into "hello.asm" then type: 1x'H#
;"nasm -f elf hello.asm" (p?7-~6|:
;"ld hello.o -o hello" 3_ P<0%
;"./hello" Yvn*evO4
R?Ou=p
.
section .data ;data section declaration >@ : m#d
msg db 'Hello World!',0AH !yQ%^g`
len equ $-msg ;string length nmN3Z_
(\zxiK
section .text ;code section declaration yV4rS6=
global _start ;entry point (start of execution) ey/=\@[p
_start: mov edx,len ;string length 6[k7e!&
mov ecx,msg ;string start 8N,mp>~
mov ebx,1 ;file handle: stdout '<R::M,
mov eax,4 ;sys_write <