“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 ky{@*fg.
-I:L6ft8
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 6?';ip
8&:dzS
以下是用不同语言写成的Hello World程序的几个例子: V#+M lN
Ada _D{{C
with Ada.Text_Io; use Ada.Text_Io; %_(^BZd
procedure Hello is B A
i ^t
begin Lh-+i
Put_Line ("Hello, world!"); Tdxc%'l
end Hello; )_kU,RvZ
m'KEN<)s
ll
^I;o0
汇编语言 RgD:"zeM
XzW\p8D^u
x86 CPU,DOS,TASM D1V^DbUm_
MODEL SMALL ;ykX]5jGh
IDEAL sWq@E6,I
STACK 100H "`V:4uz
[33=+Ca
DATASEG #[]B:
n6
HW DB 'Hello, world!$' ]4Q~x
6RfS_
CODESEG MFz6y":~
MOV AX, @data +.a->SZ5"
MOV DS, AX *iUR1V Y
MOV DX, OFFSET HW g6h=Q3@
MOV AH, 09H ;y;UgwAM
INT 21H l]L"Ex{
MOV AX, 4C00H $ VeQvm*
INT 21H !]MGIh#u
END &S[>*+}{+
z
J V>;
+;a\
gF^
x86 CPU,GNU/Linux,NASM c^~R%Bx
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). lT8^BT
;Enter this into "hello.asm" then type: l Ma||
;"nasm -f elf hello.asm" ;It1i`!R
;"ld hello.o -o hello" ahR-^^'$
;"./hello" 2U3WH.o
IIAm"=*
section .data ;data section declaration Y+C6+I<3
msg db 'Hello World!',0AH ([NS%
len equ $-msg ;string length (/|f6_9!
BAy)P1
section .text ;code section declaration AQs_(LR
global _start ;entry point (start of execution) ]eI|_O^u
_start: mov edx,len ;string length ej[Y
`N
mov ecx,msg ;string start #"TL*p
mov ebx,1 ;file handle: stdout W3xObt3w\
mov eax,4 ;sys_write Qv@)WJ="-0
int 80h ;kernel system call {'o\#4Wk
3JZ9 G79H
mov ebx,0 ;return value zrV~7$HL
mov eax,1 ;sys_exit uXdR-@80*
int 80h ;kernel system call mSp;(oQ
CMfR&G,)
=BBqK=W.d
x86 CPU,Windows,MASM32 }^PdW3O*m,
.386 4x$Ts %]
.model flat,stdcall \7q>4[
option casemap:none AE4>pzBe
;Include 文件定义 vl5r~F
include windows.inc %)L|7v<
include user32.inc F"a31`L>H
includelib user32.lib JjG>$z
include kernel32.inc ZRYHsl{F+
includelib kernel32.lib +|Mi lwr
;数据段 ^ %x7:
.data 7.B]B,]
szCaption db 'A MessageBox!',0 }#E~XlX^
szText db 'Hello,world!',0 %loe8yt
;代码段 \)BDl
.code !qJ|`o Y
start: #po}Y
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK =mh)b]].4\
invoke ExitProcess,NULL 6}q# c
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> $1myf Z
end start I< Rai"
bdr!|WZ
rY(^6[ !
AWK +WSM<