“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 5mnIQ~psR
+QtK
"5M
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 S,n*1&ogj
G9N6iKP!
以下是用不同语言写成的Hello World程序的几个例子: o" &7$pAh
Ada XlV#)JX
with Ada.Text_Io; use Ada.Text_Io; lDCoYX_
procedure Hello is _j}|R(s*+V
begin vtCt6M
Put_Line ("Hello, world!"); vbmi_[,U
end Hello; <^
@1wg
la</IpC
,wlFn
汇编语言 XcR2]\
(O\5gAx
x86 CPU,DOS,TASM zy
MODEL SMALL $FNj>1
IDEAL 8}XtVF;
STACK 100H g9<*+fV
2$
U$# ?Lw
DATASEG TlQ#0_as[
HW DB 'Hello, world!$' Xb?P'nD
?`uY*+u
CODESEG {tOu+zy
MOV AX, @data R',Q)<
MOV DS, AX ,=Xr'7w,
MOV DX, OFFSET HW *6df|q
MOV AH, 09H yS@c2I602
INT 21H q$(aMO&J
MOV AX, 4C00H k9~NIvnB`
INT 21H !L2R0Y:a
END L1VUfEG-
Ha[Bf*
brl(7_2
x86 CPU,GNU/Linux,NASM Y]Vt&*{JV
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). u+&BR1)C
;Enter this into "hello.asm" then type: CJz2.yd
;"nasm -f elf hello.asm" =!GUQLS{
;"ld hello.o -o hello" K;k_MA310
;"./hello" /$|C s
AT<K>&)
section .data ;data section declaration M`q >i B
msg db 'Hello World!',0AH z4HIDb
len equ $-msg ;string length eY-W5TgU
Xjw>Qws
section .text ;code section declaration d/v{I
global _start ;entry point (start of execution) SGXXv
_start: mov edx,len ;string length f<=<:+
mov ecx,msg ;string start S*Qip,u
mov ebx,1 ;file handle: stdout %\6|fKB4<
mov eax,4 ;sys_write :rk=(=@8`
int 80h ;kernel system call fINF;TK
07[A&