“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 nQ q=7Gu
j Dy-)2<
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 7NDr1Z#B6V
3gv|9T
以下是用不同语言写成的Hello World程序的几个例子: Y( 3Bp\6
Ada 99:C"`E{
with Ada.Text_Io; use Ada.Text_Io; n` xR5!de
procedure Hello is }dp=?AFg
begin 2.% .Z_k)
Put_Line ("Hello, world!"); ^C_#<m_k
end Hello; ppZDGpp
{$R' WXVs
x$1]M DAGb
汇编语言 fb{``,nO
;.TRWn#
x86 CPU,DOS,TASM Q$HG
MODEL SMALL k Mu8"Az
IDEAL *^f<W6xc
STACK 100H lTd #bN
U<CTubF
DATASEG p1&b!*o- &
HW DB 'Hello, world!$' VY~yg*
+6';1Nb@
CODESEG U@-^C"R
MOV AX, @data GH+r?2<
MOV DS, AX e6d<dXx
MOV DX, OFFSET HW |2abmuR0
MOV AH, 09H ?,&
tNP{jq
INT 21H kL$!E9
MOV AX, 4C00H B?4boF?~
INT 21H xL{a
END vU767/
95YL]3V
)xbHCoU,
x86 CPU,GNU/Linux,NASM MrDc$p W G
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). %kdEun
;Enter this into "hello.asm" then type: $Hj.{;eC/k
;"nasm -f elf hello.asm" G*-b}f
;"ld hello.o -o hello" T;,cN7>>O
;"./hello" kdl:Wt*4o
SzjkI+-$:
section .data ;data section declaration s (zL
msg db 'Hello World!',0AH gREzZ+([
len equ $-msg ;string length my}-s
f ` R/
i
section .text ;code section declaration <4P4u*/o
global _start ;entry point (start of execution) dYL"h.x
_start: mov edx,len ;string length (+B5|_xQu
mov ecx,msg ;string start P%#<I}0C
mov ebx,1 ;file handle: stdout NdzSz]q}
mov eax,4 ;sys_write ynE)Xdh
int 80h ;kernel system call kP-3"ACG
7PtN?;rP
mov ebx,0 ;return value ;\=M;Zt
mov eax,1 ;sys_exit W3 'q\+
int 80h ;kernel system call P/Q!<I
K#pNec
LN@F+CyDc
x86 CPU,Windows,MASM32 |NpP2|4h
.386 Zg'Q>.:
.model flat,stdcall yt.F\ [1
option casemap:none y~F,0"N\r
;Include 文件定义 ie2WL\tR4
include windows.inc FQqI<6;
include user32.inc D^=J|7e
includelib user32.lib Pmh8sw
include kernel32.inc `QyO`y=?[Y
includelib kernel32.lib {&\jW!&n
;数据段 =5kY6%E7c
.data SV2M+5#;
szCaption db 'A MessageBox!',0 Of4^?`
^
szText db 'Hello,world!',0 "x 3lQ
;代码段 Q0&H#xgt
.code cVv;Jn
start: v
8$>rwB
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK )i!o8YB
invoke ExitProcess,NULL R,pX:H+
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> TrLu~4
end start U$_xUG
WJ4li@T7V
/f|X(docI
AWK w+1|9Y
BEGIN { print "Hello, world!" } \lZf<