“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 Pu\DYP:(
i&s=!`
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 /cg]wG!n8
$et
:
以下是用不同语言写成的Hello World程序的几个例子: @,>=X:7
Ada ~|B!.+
with Ada.Text_Io; use Ada.Text_Io; S1^Mw;?P
procedure Hello is glKs8^W
begin NE>JtTF<
Put_Line ("Hello, world!"); {'K;aJ'\
end Hello; =R24h
w2C!>fJ]1
_%p9B#X<>
汇编语言 /CQQ^/
@vYN7
x86 CPU,DOS,TASM E.Q}
\E
MODEL SMALL Z :i"|;
IDEAL (+Nmio
STACK 100H 8IIdNd
!=Kay^J~.
DATASEG x;?1#W
HW DB 'Hello, world!$' 4[V6so 0
*d,n2a#n5
CODESEG hb8@br
MOV AX, @data K&P{2Hndr
MOV DS, AX *,*:6^t
MOV DX, OFFSET HW !)*T
MOV AH, 09H d# ?*62
INT 21H /wRK[i
MOV AX, 4C00H b>AAx$2Y
INT 21H <~8f0+"
END -_f0AfU/a
#uw*8&%0
/$4?.qtu
x86 CPU,GNU/Linux,NASM A)p!w aG
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). "ZPbK$+=yU
;Enter this into "hello.asm" then type: D~ `YRbv
;"nasm -f elf hello.asm" ^~1@HcJo
;"ld hello.o -o hello" }d*sWSPu(
;"./hello" Lzx(!<v
2Lu{@*
section .data ;data section declaration 9 0(oV&
msg db 'Hello World!',0AH _<~Vxz9
len equ $-msg ;string length w.F3o4YP
xfV2/A#h
section .text ;code section declaration Yw1q2jT
global _start ;entry point (start of execution) ;\&bvGj8V
_start: mov edx,len ;string length e$+? v2.
mov ecx,msg ;string start zm S-s\$,
mov ebx,1 ;file handle: stdout Mn{Rg>X
mov eax,4 ;sys_write j9fL0$+FI
int 80h ;kernel system call zs^\zCb8
?*5l}y=
mov ebx,0 ;return value /n}V7
mov eax,1 ;sys_exit /<Nt$n
int 80h ;kernel system call $gtT5{"PN(
KUn5S&eB
7Sv5fLu2
x86 CPU,Windows,MASM32 @3=<wz<
.386 xMGd'l?
.model flat,stdcall `2U/O .rV
option casemap:none 3Eux-C!t
;Include 文件定义 G,*
uj0g
include windows.inc R =c
include user32.inc #^[N4uV
includelib user32.lib G u I sM
include kernel32.inc /OtQk-E
includelib kernel32.lib 0<Y&2<v
;数据段 ?#y<^oNM
.data [5#/&k{
szCaption db 'A MessageBox!',0 lz5j~t5>Q
szText db 'Hello,world!',0 x};g!FYfkB
;代码段 s OHAW*+
.code IIEU{},}z
start: /PuWJPy;
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK .Zz7LG{
invoke ExitProcess,NULL ^[NmNi*
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "_}D{ws1
end start WC&Ltw8
T:n^$RiT
#IJKMSGw?E
AWK (NV=YX?s
BEGIN { print "Hello, world!" } WD1$"}R
~$obcW1
-Af`AX
BASIC ] ]-0RJ=S?
传统版BASIC(例如GWBASIC): '(:J|DN
TZ]Gl4@
10 PRINT "Hello, world!" ! yUKNR
20 END Z- Ae'ym
P@![P Ij
或在提示符输入: ]h8V{%H
*Bz&