“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 :2')`xT
'C#[iRG4
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 G%=
gCR
p{``a=
以下是用不同语言写成的Hello World程序的几个例子: K@
&;f(Y
Ada ]^i^L
with Ada.Text_Io; use Ada.Text_Io; Kc#1H|'2N
procedure Hello is ^\Q%VTM
begin n[# **s
Put_Line ("Hello, world!"); ya,-Lt
end Hello; #^$_3AY
acQHqR
T7O)
汇编语言 A4b+:MQ*OX
L.}sN.
x86 CPU,DOS,TASM ?C
MODEL SMALL dxtG3
IDEAL 5@I/+D
STACK 100H oJ/=&c
~,xso0
DATASEG 5P 5Tgk
HW DB 'Hello, world!$' h'_$I4e)
U)Tl<l<
CODESEG J(=y$8xje
MOV AX, @data t)~$p#NS
MOV DS, AX H\9ePo\b~
MOV DX, OFFSET HW crSqbL
MOV AH, 09H 0<fQjXn
INT 21H )p:+!sX(
MOV AX, 4C00H )V*`(dn'zm
INT 21H ^gR~~t;@
END sb?!U"v.'
[qkc6sqo
>RpMw!NT
x86 CPU,GNU/Linux,NASM TgJ6O,0
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). R|Uu
;Enter this into "hello.asm" then type: zG^$-L.n
;"nasm -f elf hello.asm" P4|A\|t
;"ld hello.o -o hello" 6VJS
l%X
;"./hello" _g,_G
k5+ Fxf
section .data ;data section declaration %mzDmrzq
msg db 'Hello World!',0AH yw89*:A6
len equ $-msg ;string length :QXKG8^
aMJ2bu
section .text ;code section declaration "s(|pQh;
global _start ;entry point (start of execution) 2d
YU
_start: mov edx,len ;string length \(`C*d
mov ecx,msg ;string start I#7H)^us
mov ebx,1 ;file handle: stdout 9JJ6$cLF
mov eax,4 ;sys_write @uG/2'B(
int 80h ;kernel system call ~d ~oC$=TC
Xf
mN/j2
mov ebx,0 ;return value H6`zzH0"
mov eax,1 ;sys_exit jX*gw6!
int 80h ;kernel system call HsT6 #K
NJOV!\k
%*IH~/Ld;]
x86 CPU,Windows,MASM32 ((^vsKT
.386 !0):g/2h
.model flat,stdcall cFuQ>xR1
option casemap:none WHfl|e
;Include 文件定义 4\uq$.f-
include windows.inc ~~I]SI k{
include user32.inc X?/32~\
includelib user32.lib C+mPl +}w
include kernel32.inc G(t&(t`[
includelib kernel32.lib ]"j%:fr
;数据段 .G"T;w6d
.data #$!^1yO
szCaption db 'A MessageBox!',0 x`'s
szText db 'Hello,world!',0 %>y!N!.F
;代码段 #]^M/y
h
.code F*NHy.Y
start: dwiLu& ]u
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK ]I;owk,
invoke ExitProcess,NULL U<'z,Px6
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 7ks!0``
end start BrZ17
;$qc@)Uwp
m93{K7O2e
AWK g|4>S<uC
BEGIN { print "Hello, world!" } * )HVK&