“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 k|$?b7)"@
O"wo&5b_
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 HIda%D
AmrVxn4
以下是用不同语言写成的Hello World程序的几个例子: H% FP!03
Ada 9{Igw"9ck
with Ada.Text_Io; use Ada.Text_Io; 3il$V78|
procedure Hello is #Fkp6`Q$x
begin <&tdyAT?&
Put_Line ("Hello, world!"); E0.o/3Gw6
end Hello; - *qoF(/U
<KX+j,4
N l^uA
汇编语言 o* e'D7
rx@2Dmt6
x86 CPU,DOS,TASM 7v}(R:*
MODEL SMALL 9xeg,#1
IDEAL gOMy8w4>
STACK 100H ^b
3nEcQn
vSo1WS
DATASEG *hh9
K
HW DB 'Hello, world!$' cI-@nV
*DvQnj
CODESEG #VsS C1
MOV AX, @data 1/%5pb2\
MOV DS, AX onm"7JsO'
MOV DX, OFFSET HW @S 0mNA
MOV AH, 09H CtZOIx.;|
INT 21H D-e?;<
MOV AX, 4C00H q``/7
INT 21H -]G=Q1 1
END fnIF<Zt
c GyBml1
tRNMiU
x86 CPU,GNU/Linux,NASM *d31fBCk%
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). Zh_3ydMD1
;Enter this into "hello.asm" then type: 5ka6=R(r
;"nasm -f elf hello.asm" /x\~5cC
;"ld hello.o -o hello" V5gr-^E
;"./hello" _>_"cKS
h;R>|2A
section .data ;data section declaration G[n;%c~`+
msg db 'Hello World!',0AH P1|3%#c
len equ $-msg ;string length 9<o*aFgCa
# hw;aQ
section .text ;code section declaration WA.c.{w\
global _start ;entry point (start of execution) %AA-G
_start: mov edx,len ;string length 5Ha(i [d
mov ecx,msg ;string start c= aZ[
mov ebx,1 ;file handle: stdout E&)o.l<h|
mov eax,4 ;sys_write m ;wj|@cF
int 80h ;kernel system call V{X/y N.u
=Z..&H5i
mov ebx,0 ;return value x@D>JG
mov eax,1 ;sys_exit 3,J{!
int 80h ;kernel system call V;gC[7H
L1&` 3a?pL
bGK-?BE5+A
x86 CPU,Windows,MASM32 ^ Z3y
.386 ft~QVe!
.model flat,stdcall 'r1X6?dJ
option casemap:none RFq=`/>dG
;Include 文件定义 X.ZG-TC
include windows.inc Ml/K~H
tN
include user32.inc r4 qs!(
includelib user32.lib Z_>:p^id
include kernel32.inc =F_j})O5
includelib kernel32.lib Ox@$ }
;数据段 !E,|EdIr
.data \\{78WDA
szCaption db 'A MessageBox!',0 w}8=sw
szText db 'Hello,world!',0 SZ:R~4 A
;代码段 zoBp02j
.code VBW][f
start: -b34Wz(
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK !j3Xzn9
invoke ExitProcess,NULL R_2#7Xs
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> h!tg+9%
end start "![KQ
uE>m3Y(aP
{fY(zHC
AWK >y$*|V}k
BEGIN { print "Hello, world!" } X|L_}Q7
fw|t`mUGu
w^:@g~
BASIC 5i'KGL
传统版BASIC(例如GWBASIC): O%<+&