“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 < ?{ic2j#
ic=tVs
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 mnm7{?#[
IDn$w^"
以下是用不同语言写成的Hello World程序的几个例子: ~/m=Q<cV
Ada dW#T1mB
with Ada.Text_Io; use Ada.Text_Io; 5h7M3s
procedure Hello is ApSzkPv*
begin ^jB17z[
Put_Line ("Hello, world!"); +.pri
end Hello; efXiZ
#BhDC.CcW
p"tCMB
汇编语言 Wz&[cj
_/[}PQC6G
x86 CPU,DOS,TASM ,qu7XFYrY
MODEL SMALL ^_5t5>
IDEAL d]r?mnN W
STACK 100H MiN|u
C.N#y`g
DATASEG OYLg-S
HW DB 'Hello, world!$' F\Q X=n
7N4)T'B
CODESEG 5=hMTztf!!
MOV AX, @data 6R'z3[K9
MOV DS, AX kkU#0p? 7
MOV DX, OFFSET HW kA4bv}
MOV AH, 09H 1Rd2Xb
INT 21H tYUg%2G
MOV AX, 4C00H Q$58K9
INT 21H K*9~g('
END U>0~ /o
Nf!WqD* je
VxW>XxG0
x86 CPU,GNU/Linux,NASM 8{DW$ZtR
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). f~P~%
;Enter this into "hello.asm" then type: 3{H&{@Q
;"nasm -f elf hello.asm" 0@>
;"ld hello.o -o hello" c@|f'V4
;"./hello" (MzThGJK_
,R[<+!RS
section .data ;data section declaration 6(8zt"E
msg db 'Hello World!',0AH ZO8r8
[
len equ $-msg ;string length ["0DXm%t
iT=h}>
section .text ;code section declaration B+4WnR1%T
global _start ;entry point (start of execution) )~be<G( a
_start: mov edx,len ;string length $Y?[[>u
mov ecx,msg ;string start 7RCVqc"
mov ebx,1 ;file handle: stdout q_86nvB<
mov eax,4 ;sys_write <V1y^EW0
int 80h ;kernel system call <[A;i
OICH:(t_
mov ebx,0 ;return value MmH(dp+
mov eax,1 ;sys_exit Y$0K}`{
int 80h ;kernel system call @pN6uDD}R
yW@YW_2;4
zn#lFPj12
x86 CPU,Windows,MASM32 t*wV<b
.386 n'9&q]GN|
.model flat,stdcall M,sZ8eeq
option casemap:none `N;O6
wZ
;Include 文件定义 CF]#0*MI
include windows.inc ffG1QvC|M
include user32.inc cpu|tK.t
includelib user32.lib q854k+C
include kernel32.inc 3(3-#MD0
includelib kernel32.lib N[&(e
d=
;数据段 |\T!,~
.data v(`5exWV
szCaption db 'A MessageBox!',0 }WnoI2
szText db 'Hello,world!',0 chXTFLC~
;代码段 WQBpU?O
.code aC#{@t
start: %`0*KMO3
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK $g '4'
invoke ExitProcess,NULL [/Xc},HbMe
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ^ 2LqKo\T
end start nVoP:FHH
8V@\$4@b!#
C]M{
AWK plgiQr #
BEGIN { print "Hello, world!" } 7VW/v4n
u&<