“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 `ehZ(H}
jL|y4
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 wX0m8"g@
q*Hf%I"
以下是用不同语言写成的Hello World程序的几个例子: w/L^w50pt
Ada |r]f2Mrm
with Ada.Text_Io; use Ada.Text_Io; fjE
procedure Hello is urlwn*!^s
begin (|6Y1``
Put_Line ("Hello, world!"); p m4g),s
end Hello; v{N4*P.0T
Y1?"Ut
/-#1ys#F=
汇编语言 )w{bT]
^l UV^%f
x86 CPU,DOS,TASM d ,Fj|}S
MODEL SMALL oBA]qI
IDEAL H O^3v34ZO
STACK 100H ~{#$`o=
>t[beRcR6
DATASEG C+*qU
HW DB 'Hello, world!$' U5 `h
GAZTCkB"
CODESEG [3yzVcr~4
MOV AX, @data 4k
HFfc
MOV DS, AX RGeM.
MOV DX, OFFSET HW :QndeUw
MOV AH, 09H GTj=R$%09
INT 21H o]&w"3vOP0
MOV AX, 4C00H P%#EH2J
INT 21H 9@Iz:!oqb
END '`-W!g[
>
AhZ`hj
h6*&1r
x86 CPU,GNU/Linux,NASM `A]CdgA
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). %uuh+@/&yz
;Enter this into "hello.asm" then type: )JO#Z(
;"nasm -f elf hello.asm" ArFsr
;"ld hello.o -o hello" Kk}|[\fW
;"./hello" <Rs#y:
h\oAW?^
section .data ;data section declaration kQ,#NR/q6
msg db 'Hello World!',0AH }!5x1F!
len equ $-msg ;string length B! `Dj,_
P87!+pB(
section .text ;code section declaration I9! eL4e
global _start ;entry point (start of execution) DcNQ2Zz?%
_start: mov edx,len ;string length %idn7STJ}
mov ecx,msg ;string start E%eTjvvxus
mov ebx,1 ;file handle: stdout dQ6n[$Q@N
mov eax,4 ;sys_write m;=wQYFr{I
int 80h ;kernel system call SIJ:[=5!7
IL:d`Kbqf
mov ebx,0 ;return value xiu?BP?V
mov eax,1 ;sys_exit b`NXe7A
int 80h ;kernel system call jV(\]g"/=
>&@hm4
`1cGb *b/
x86 CPU,Windows,MASM32 p2c4 <f-M
.386 3:">]LMi
.model flat,stdcall }{! #`'s
option casemap:none [0_JS 2KE
;Include 文件定义 `EV"
/&`
include windows.inc a@|/D\C
include user32.inc 9Tgl/}q)
includelib user32.lib /5:f[-\s
include kernel32.inc i+/:^tc;
includelib kernel32.lib U({20
;数据段 H-?wEMi)*u
.data h'i8o>7
szCaption db 'A MessageBox!',0 9;Z2.P"w
szText db 'Hello,world!',0 63s<U/N
;代码段 +N161vo7
.code ?[$=5?
start: BrW1:2w
>\
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK uCA!L)$
invoke ExitProcess,NULL @/S6P-4
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> IrAc&Eh