“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 0O,Q]P 82f
kkvG=
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 J0{;"
QLr.5Wcg>
以下是用不同语言写成的Hello World程序的几个例子: J['pBlEb\
Ada F#<$yUf%
with Ada.Text_Io; use Ada.Text_Io; )zUbMzF
procedure Hello is IEbk_-h[
begin B!>hHQ2
Put_Line ("Hello, world!"); ?<mxv"
end Hello; }q-* Ls~
V4~`yT?*"
ga BVD*>
汇编语言 =a!w)z_rw
gK8E|f-z
x86 CPU,DOS,TASM x=Ef0v
MODEL SMALL ?g7O([*[
IDEAL ZT;8Wvo
STACK 100H tQTVP 2:Y
Gp&o
DATASEG tCoT-\Q
HW DB 'Hello, world!$' (P=q&]l[
2D`_!OG=
CODESEG \piHdVD
MOV AX, @data ,\2w+L5TD
MOV DS, AX ]Ak/:pu
MOV DX, OFFSET HW Zt3Y<3o
MOV AH, 09H w-2?|XvDmf
INT 21H ;:)1:Dy5
MOV AX, 4C00H VMa\?`fT
INT 21H iLvzoQ
END (fSpY\JPI
[\41
86_`Z$ s
x86 CPU,GNU/Linux,NASM y9/x:n&]
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). 9hbn<Y
;Enter this into "hello.asm" then type: 7[ 82~jM[
;"nasm -f elf hello.asm" Q^p>hda
;"ld hello.o -o hello" s,~p}A%0
;"./hello" 'f'zV@)
k|kn#X3X
section .data ;data section declaration A9:dHOmT^U
msg db 'Hello World!',0AH !Z0p94L
len equ $-msg ;string length iS/faXe5
KUR9vo
section .text ;code section declaration c)5d-3"
global _start ;entry point (start of execution) xzI?'?duC
_start: mov edx,len ;string length klUW_d-
mov ecx,msg ;string start XkGS3EY
mov ebx,1 ;file handle: stdout ZSs)AB_Pe/
mov eax,4 ;sys_write /8$*{ay
int 80h ;kernel system call pb`!_GmB
mrc% 6Ri
mov ebx,0 ;return value =Su~iOa
mov eax,1 ;sys_exit 0P?\eoB@8
int 80h ;kernel system call N51g<K
xoT|fgb
e7# B?
x86 CPU,Windows,MASM32 .UdoB`@!v=
.386 1I^uq>r
.model flat,stdcall !%8|R]d
option casemap:none +?&|p0
;Include 文件定义 8M5a&