“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 oW/&X5
T`W FY
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 pH"LZ7)DI0
qKSM*k~
以下是用不同语言写成的Hello World程序的几个例子: r!x^P=f,MJ
Ada %b!p{p
with Ada.Text_Io; use Ada.Text_Io; nFB;! r
procedure Hello is WQK#&r*
begin !w/~dy
Put_Line ("Hello, world!"); 2{#quXN9
end Hello; 6DR8(j)=[%
!'[sV^ds
wCI.jGSBW
汇编语言 i_=P!%,
' bT9AV%
x86 CPU,DOS,TASM 8KAyif@1::
MODEL SMALL gK%&VzG4
IDEAL S$$:G$j
STACK 100H IO6i
s*!2oj
DATASEG lYZHM,"
HW DB 'Hello, world!$' >ZNL
pJQ
f0^s*V+
CODESEG c}{e,t
MOV AX, @data tHu8|JrH+
MOV DS, AX &[s^`e
MOV DX, OFFSET HW Y.hrU*[J0
MOV AH, 09H +"p",Z
INT 21H bMv9f
J
MOV AX, 4C00H L4[bm[x
INT 21H 4wBCs0NIm
END `9wz:s QtP
MWB uMF
qi)(\
x86 CPU,GNU/Linux,NASM c?opVbJB\
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). d[o =
;Enter this into "hello.asm" then type: >T(f
;"nasm -f elf hello.asm" IC{>q3
;"ld hello.o -o hello" I|`K;a
;"./hello" {QhvHV
D!X{9q}S1
section .data ;data section declaration }`h}h<B(
msg db 'Hello World!',0AH O&O1O>[p1
len equ $-msg ;string length h]D=v B
:s$9#}hw,
section .text ;code section declaration -J[D:P.Z
global _start ;entry point (start of execution) a.Mp1W
_start: mov edx,len ;string length ;pU LJ}rDb
mov ecx,msg ;string start Ia(A&Za
mov ebx,1 ;file handle: stdout I&cb5j]C
mov eax,4 ;sys_write (te\!$
int 80h ;kernel system call %WO;WxG8^
=LT( {8
mov ebx,0 ;return value F*NIs:3;
mov eax,1 ;sys_exit A2+t`[w
int 80h ;kernel system call d?S<h`{x
jV7q)\uu^
r[?rwc^
x86 CPU,Windows,MASM32 +0=RC^
.386 *PMql $
.model flat,stdcall ++kiCoC
option casemap:none ,)Q mQ^/
;Include 文件定义 r1=Zoxc=w
include windows.inc ;=n7 Z
include user32.inc JEP"2M N,
includelib user32.lib fN K~z*
include kernel32.inc N..u<06j/
includelib kernel32.lib 2`Pk@,:_
;数据段 Lc.7:r
.data Us%VBq
szCaption db 'A MessageBox!',0 i>rn!?b
szText db 'Hello,world!',0 dIf Jr}ih
;代码段 SS`\,%aog
.code yV]-![`D
start: 2.NzB7c*CM
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK r@!~l1$s`
invoke ExitProcess,NULL a
v`eA`)S
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> F_-yT[i
end start =-q)I[4#
=djzE`)0
#h&?wE>
AWK S9L3/P]
BEGIN { print "Hello, world!" } LEhi/>T
T&S<