“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 9hIKx:XCg
*{w0=J[15
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 K/
On|C
KM?4J6jH
以下是用不同语言写成的Hello World程序的几个例子: AuXUD9-
Ada ?^%[*OCCC!
with Ada.Text_Io; use Ada.Text_Io; R<&Euph
procedure Hello is Z2$_9.
begin 3E|||3rf
Put_Line ("Hello, world!"); sq_>^z3T
end Hello; ^~[7])}g6
dw <i)P^
]H
n:c'aT
汇编语言 larv6ncV
rc8HZ
x86 CPU,DOS,TASM ]%6%rq%9C
MODEL SMALL J -z.
IDEAL "mJo<i}
STACK 100H B46:LQ9[
BjH|E@z
DATASEG 7He"IJ
HW DB 'Hello, world!$' #'&-S@/nQs
CB#2XS>V
CODESEG ,'(|,f42
MOV AX, @data m=6?%'
H}
MOV DS, AX }'P|A
MOV DX, OFFSET HW 0cHcBxdF
MOV AH, 09H 0BC@wV
INT 21H wMCMrv:
MOV AX, 4C00H :(~<BiqR(
INT 21H ^`yhN
END )W\)kDh!
RDbNC v#
EcHZmf
x86 CPU,GNU/Linux,NASM @JlT*:Dz
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). .vKgiIC:
;Enter this into "hello.asm" then type: _ooHB>sH
;"nasm -f elf hello.asm" 6h/!,j0:t_
;"ld hello.o -o hello" zRjbEL
;"./hello" [1(eSH
J0IKI,X.
section .data ;data section declaration 8
siP
msg db 'Hello World!',0AH X]}ai5
len equ $-msg ;string length ^IiA(?8
%t&Lq }e
section .text ;code section declaration 0t!ZMH
global _start ;entry point (start of execution) [Z/P[370
_start: mov edx,len ;string length ByjfPb#
mov ecx,msg ;string start |iJz[%
mov ebx,1 ;file handle: stdout P7}w^#x
mov eax,4 ;sys_write DH.`
int 80h ;kernel system call h:Gs9]Lvtv
2+pw%#fe
mov ebx,0 ;return value Z|@-=S(.
mov eax,1 ;sys_exit x%X3FbF]
int 80h ;kernel system call nycJZ}f:wP
bP$e1I3`
uvl91~&G
x86 CPU,Windows,MASM32 'dwsm7Xd
.386 }%w;@[@L
.model flat,stdcall vH6(p(l
option casemap:none fPN/Mxu
;Include 文件定义 !pe[H*Cy
include windows.inc 7y&