“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 ]/v[8dS(l
h_'*XWd@
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 upmx $H>
&D<y X~
以下是用不同语言写成的Hello World程序的几个例子: y9ZvV0
Ada F^:3?JA_
with Ada.Text_Io; use Ada.Text_Io; 75lA%|
*X
procedure Hello is N!}f}oF
begin g_bLl)g<
Put_Line ("Hello, world!"); ]-#DB^EQ
end Hello; ob]w;"
W>r+h-kR
J&_n9$
汇编语言 Le^ n +5x
;xTpE2 -~
x86 CPU,DOS,TASM SXh-A1t
MODEL SMALL "tK=+f`NM
IDEAL PKz':_|
STACK 100H !N^@4*
m&3xJuKih
DATASEG gSj,E8-g
HW DB 'Hello, world!$' R;LP:,)
OyIw>Wfv
CODESEG "AqB$^S9t
MOV AX, @data 8oGRLYU N
MOV DS, AX -~w'Xo #
MOV DX, OFFSET HW $??I/6
MOV AH, 09H H PVEnVn
INT 21H d'> x(Yi
MOV AX, 4C00H QJ;2ZN,
INT 21H c+ie8Q!
END ueNS='+m
*un^u-;
pxi3PY?
x86 CPU,GNU/Linux,NASM #'}*dy/
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). :`sUt1Fw.
;Enter this into "hello.asm" then type: h68 xet;
;"nasm -f elf hello.asm" &p,]w~d,U
;"ld hello.o -o hello" ]?4hyN
;"./hello" (9)Q ' 'S
$~)SCbL^5
section .data ;data section declaration (8OsGn
msg db 'Hello World!',0AH 3so%gvY.'
len equ $-msg ;string length l]SX@zTb
='jT~\
section .text ;code section declaration WIGi51yC.x
global _start ;entry point (start of execution) rJB}qYD
_start: mov edx,len ;string length 9gIrt 6
mov ecx,msg ;string start 6]wIG$j
mov ebx,1 ;file handle: stdout ,esmV-
mov eax,4 ;sys_write ar,7S&s