“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 oI=fx Sjd
M^O2\G#B
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 4[.oPK=i
"]"|"0#i
以下是用不同语言写成的Hello World程序的几个例子: 9Xj7~,
Ada 5k`l$mW{
with Ada.Text_Io; use Ada.Text_Io; HW=C),*]cR
procedure Hello is q#T/
begin QIB\AAclO
Put_Line ("Hello, world!"); OHeT,@(mh
end Hello; Z1 Bp+a3
v:!Z=I}>
i&5XF
汇编语言 xCg52zkH#
]!I7Y.w6
x86 CPU,DOS,TASM ;g @4|Ro
MODEL SMALL ba[1wFmcL
IDEAL -n=^U
STACK 100H SSPHhAeH8
X' d9[).
DATASEG F ~^Jmp7Y
HW DB 'Hello, world!$' ,eTUhK
lwrCpD.
CODESEG ?)kG A$m#
MOV AX, @data gu0j.XS^
MOV DS, AX G_0(
|%
MOV DX, OFFSET HW +Af"f' )
MOV AH, 09H %/|9@e r
INT 21H :pGaFWkvO
MOV AX, 4C00H M-1ngI0H;
INT 21H #
WAZ9,t
END cd(GvX'
+3BBQ+x!
/W>iJfx
x86 CPU,GNU/Linux,NASM pi
Z[Y
5OE
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). np8gKVD
;Enter this into "hello.asm" then type: 2 lj'"nm
;"nasm -f elf hello.asm" 4)@mSSfn.
;"ld hello.o -o hello" MUTj-1 H6)
;"./hello" LcUh;=r}&
wgamshm"d
section .data ;data section declaration |N%fMPKa
msg db 'Hello World!',0AH VFRi1\G
len equ $-msg ;string length l038%U~U!
77\]B
section .text ;code section declaration Xs~[&
global _start ;entry point (start of execution) n?- })
_start: mov edx,len ;string length $,,op(
mov ecx,msg ;string start %Z):>'
mov ebx,1 ;file handle: stdout k@/sn(x
mov eax,4 ;sys_write 9~p[
int 80h ;kernel system call n2)@S0{
_#r+ !e
mov ebx,0 ;return value xT
mov eax,1 ;sys_exit @\f^0^G
int 80h ;kernel system call :_g$.h%%
"Y~:|?(@-
G+X
Sfr
x86 CPU,Windows,MASM32 n)^i/ nXb'
.386 P} 0%-JC
.model flat,stdcall _$
+^q-
option casemap:none ;[M}MFc/`
;Include 文件定义 hRUhX[
include windows.inc v7iuL6jl
include user32.inc mF,Y?ax
includelib user32.lib 9}PhN<Gd
include kernel32.inc uBNn6j
includelib kernel32.lib mP0yk|
;数据段 ^(f"v
e#7v
.data #~C]ZrK
szCaption db 'A MessageBox!',0 $ZugBh[b
szText db 'Hello,world!',0 {<R2UI5m5
;代码段 d$ x"/A]<
.code ??M"6k
start: {>DEsO
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK )qo {c1X
invoke ExitProcess,NULL A8uVK5
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> G(p`1~xm
end start i36eBjT
-*
WXMzr
925|bX6I
AWK n1ly
y0%u
BEGIN { print "Hello, world!" } !cO]<