“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 L!?v BL
>,kL p|gA
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 >G<4Ro"
f_~}X#._
以下是用不同语言写成的Hello World程序的几个例子: =obt"K%n
Ada PIgGXNo
with Ada.Text_Io; use Ada.Text_Io; 3,%nkW
procedure Hello is 9)jo7,VM
begin @>+^W&
Put_Line ("Hello, world!"); .zQ4/
end Hello; YfV"_G.ad|
=jsx(3V
ZUv
ZNf
汇编语言 =kwb`
Z/a
7Y%!,ff
x86 CPU,DOS,TASM yB
1I53E
MODEL SMALL !?S5IGLOj
IDEAL FK-}i|di
STACK 100H wEZ,49
>-UD]?>
DATASEG H]Y#pLu|
HW DB 'Hello, world!$' i<'{Y
~K4k'
CODESEG $,}Qf0(S
MOV AX, @data mgk64}K [n
MOV DS, AX +[>yO _}
MOV DX, OFFSET HW jG
=(w4+
MOV AH, 09H A1mYkG)l
INT 21H f&=K]:WDe
MOV AX, 4C00H @gs26jX~2}
INT 21H 37J\i ]
END <GSQ2bX[
ww-XMz h
JqL<$mSep
x86 CPU,GNU/Linux,NASM ]lymY _ >
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). &uv>'S#%
;Enter this into "hello.asm" then type: :yd=No@
;"nasm -f elf hello.asm" %j~9O~-
;"ld hello.o -o hello" .@4Q kG/
;"./hello" *U( 1iv0n
j7QBU
section .data ;data section declaration qJ#L)
msg db 'Hello World!',0AH xAR^
len equ $-msg ;string length m]bL)]Z
c ,Qw;
section .text ;code section declaration tVC@6Z$
global _start ;entry point (start of execution) ^nG1/}
_start: mov edx,len ;string length J&
1X
mov ecx,msg ;string start \/?
!
6~
mov ebx,1 ;file handle: stdout 516VQ<