“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 _Fv6S}~Q
O)&ME
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 GuL0:,
F>[^m Xw
以下是用不同语言写成的Hello World程序的几个例子: 7OXRR)]V
Ada A93(} V7I
with Ada.Text_Io; use Ada.Text_Io; :(3'"^_NA
procedure Hello is g?}h*~<b
begin QP!;Gwqr
Put_Line ("Hello, world!"); 9T`YHA'g
end Hello; rXTdhw?+
UN;U+5,t
g}9heR
汇编语言 r,vSDHb`j
+[S<"}ls7
x86 CPU,DOS,TASM aGE}
EK }
MODEL SMALL >oEFuwE
IDEAL i{Q,>Rt
STACK 100H tLdQO"
m#6p=E
DATASEG 9v
,y
HW DB 'Hello, world!$' =ty{ugM<
B*QLKO:)i
CODESEG QT1oU P#*
MOV AX, @data P$clSJW
MOV DS, AX %,Y^Tp
MOV DX, OFFSET HW OH
88d:
MOV AH, 09H %/s+-j@s:
INT 21H qCm%};yt
MOV AX, 4C00H w5Ucj*A\
INT 21H G(hnrRxn
END oVfRp.a
>7W8_6sC<
}1sd<<\`
x86 CPU,GNU/Linux,NASM poqNiOm4%
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). O#vIn}
;Enter this into "hello.asm" then type: "88<{x L
;"nasm -f elf hello.asm" &&96kg3
;"ld hello.o -o hello" ?i~mt'O
;"./hello" {qS Ye!`
5'(#Sf
section .data ;data section declaration @_;vE(!5
msg db 'Hello World!',0AH +]C|y ,r
len equ $-msg ;string length +6<g N[
~}K$z
section .text ;code section declaration ]XfROhgP=
global _start ;entry point (start of execution) 5VLC\QgK^
_start: mov edx,len ;string length 8)}A}x
mov ecx,msg ;string start 3J^'x
mov ebx,1 ;file handle: stdout ITU6Eq
mov eax,4 ;sys_write "j}fcrlG9
int 80h ;kernel system call emS7q|^
R&L^+?
mov ebx,0 ;return value Iw</X}#\
mov eax,1 ;sys_exit z}P1+Pm
int 80h ;kernel system call P;p20+
a
,<u
2wYY0=k2
x86 CPU,Windows,MASM32 F8*P/<P1cK
.386 <\\,L@
.model flat,stdcall L' x[wM0w;
option casemap:none 4Mjcx.21
;Include 文件定义 SRyot:l
include windows.inc SA-r61
include user32.inc Ky[-ZQQo=5
includelib user32.lib (d=knoo7A
include kernel32.inc 4VlQN$
includelib kernel32.lib /y5a~3
;数据段 Ap%tm)@1
.data 1\if XJ
szCaption db 'A MessageBox!',0 >l0D,-O]m
szText db 'Hello,world!',0 =:7OS>x
;代码段 7D)i]68E
.code :|E-Dx4F6H
start: pU5t,
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK 3Qoa?*
invoke ExitProcess,NULL v.e~m2u_F
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> dIRSgJ`
end start +Zo&c}
P{h$> 6c
8>~\R=SC
AWK gye'_AR?k
BEGIN { print "Hello, world!" } G'
a{;3
s*.&DN
b:>t1S Ul
BASIC $56Z/*
传统版BASIC(例如GWBASIC): 4"y1M=he
[%yCnt
10 PRINT "Hello, world!" \>GHc}
20 END j`$d W H/2
Q GQ}I
或在提示符输入: ~xP4}gs1
uS,XQy2
?"Hello, world!":END 9 54O=9PQ
(}NKW
现代版BASIC(例如Quick BASIC): O!#bM< *
f6-OR]R5
Print "Hello, world!" 8<