“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 *r|Zbxf(
2?kVbF
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 N9 TM
+Ou<-EQV
以下是用不同语言写成的Hello World程序的几个例子: -%TwtO<$']
Ada }fL
] }&
with Ada.Text_Io; use Ada.Text_Io; G6p R?K+
procedure Hello is <4P.B?-/t
begin X3HJ3F;==
Put_Line ("Hello, world!"); k,LaFe`W
end Hello; 1pP q)}=+
t|C?=:_
>OKc\m2%Q
汇编语言 %lGT|XrY
W4"1H0s`l
x86 CPU,DOS,TASM c3(0BSv
MODEL SMALL ]0=THq\H
IDEAL ';LsEI[
STACK 100H 3{M0iNc1
&Z%'xAOGR
DATASEG o.wXaS8
HW DB 'Hello, world!$' SK5__Ix
7>f)pfLM
CODESEG vHN/~k#
MOV AX, @data 2XyC;RWJ%
MOV DS, AX Z/LYTo$Bz
MOV DX, OFFSET HW _ygdv\^Tet
MOV AH, 09H [a7S?%>Bh
INT 21H .&.L@CRH
MOV AX, 4C00H 74a k|(!
INT 21H ]F #0to
END RmQ>.?
e}ivvs2
.}Hs'co
x86 CPU,GNU/Linux,NASM wsgT`M'J[
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). q#`;G,rs
;Enter this into "hello.asm" then type: n<Ki.;-ZE
;"nasm -f elf hello.asm" 4KY@y?H g
;"ld hello.o -o hello" ([]\7}+8
;"./hello" {6iHUK
[ZD`t,x(
section .data ;data section declaration NN~PWy1opa
msg db 'Hello World!',0AH EUS^Gtc
len equ $-msg ;string length $E^*^({
!J(6E:,b#
section .text ;code section declaration [Vj|fy4
global _start ;entry point (start of execution) !X 0 (4^
_start: mov edx,len ;string length mV}eMw
mov ecx,msg ;string start 'grb@+w(
mov ebx,1 ;file handle: stdout B RtT 7
mov eax,4 ;sys_write iOiXo6YE
int 80h ;kernel system call rLcXo%w
p7[&H