“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 U: 9&0`k(
>;fVuy
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 sU_K^=6*
f@OH~4FG
以下是用不同语言写成的Hello World程序的几个例子: o7) y~ ke
Ada )(}[S:`
with Ada.Text_Io; use Ada.Text_Io; Dp'urf\*$
procedure Hello is uC'-: t#
begin Ln&pe(c
Put_Line ("Hello, world!"); ;sB=f
end Hello; E'QAsU8pP
-+".ut:R
I\@r~]+y
汇编语言 *QC6zJ
.hT>a<
x86 CPU,DOS,TASM O =Z}DGa+
MODEL SMALL .a%6A#<X
IDEAL *[Hp&6f
STACK 100H dAI^ P/y%
='7m$,{(Q[
DATASEG n ay\)
HW DB 'Hello, world!$' HsCL%$k
uJ% <+I
CODESEG 7>Scf
MOV AX, @data 22l'kvo4"
MOV DS, AX !dqC6a
MOV DX, OFFSET HW Kr}RFJ"d
MOV AH, 09H BIx*t9wA
INT 21H EmNVQ1w
MOV AX, 4C00H Za|7gt];l
INT 21H q*hn5 K*
END */aY$aWv
.n 9.y8C
k6tCfq;
x86 CPU,GNU/Linux,NASM =M\yh,s!
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). bxXpw&
;Enter this into "hello.asm" then type: >q}3#TvP@
;"nasm -f elf hello.asm" 0Wr<l%M)+
;"ld hello.o -o hello" 14,)JZN
;"./hello" s9?mX@>h
{ 53FR
section .data ;data section declaration H=/1d.p
msg db 'Hello World!',0AH ]iV]7g8:
len equ $-msg ;string length V3,C5KKk&z
9jal D
X
section .text ;code section declaration `G\
qGllX
global _start ;entry point (start of execution) e{)giJY9
_start: mov edx,len ;string length z|g2Q#$-\S
mov ecx,msg ;string start 4 9qa
mov ebx,1 ;file handle: stdout e@'x7Zzh
mov eax,4 ;sys_write \8{SQ%
int 80h ;kernel system call lu#a.41
}z]d]
mov ebx,0 ;return value ?^&ih:"
mov eax,1 ;sys_exit A c_P^
int 80h ;kernel system call -laH^<jm5
ql?w6qFs]
|_53So:g
x86 CPU,Windows,MASM32 )~'UJPK
.386 uLdHE5vr
.model flat,stdcall 5wK==hZ
option casemap:none vl (``5{
;Include 文件定义 1g;2e##)
include windows.inc }8O9WS
include user32.inc }&v}S6T
includelib user32.lib L$ T2 bul
include kernel32.inc "aGmv9\
includelib kernel32.lib rZUTBLZ`j
;数据段 (kL"*y/"p
.data 4
]oe`yx
szCaption db 'A MessageBox!',0 x?i
wtZ@
szText db 'Hello,world!',0 %JeNDXbI4
;代码段 !'$*Z(
.code frcAXh9
start: bJ2-lU% ;2
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK >N^<Q4%2
invoke ExitProcess,NULL cW3'057
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> wSR|uh
end start 49FP&NgK
XDK Me}
{4+/0\
AWK :!i=g+e]
BEGIN { print "Hello, world!" } cS.@02~f"
g~<[;6&