“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 F)Qj<6
_!'sj=n]q
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 7J$5dFV2
wG2-,\:
以下是用不同语言写成的Hello World程序的几个例子: Q{))+'s2h
Ada GK.U_` 4?
with Ada.Text_Io; use Ada.Text_Io; 8~s-@3J
procedure Hello is AcCM
W@e
begin `h+1u`FJ
Put_Line ("Hello, world!"); nbM7 >tnsk
end Hello; .}||!
YkqauyV^
@Tl!A1y?
汇编语言 GP,xGZZ
eV x
&S a
x86 CPU,DOS,TASM r")zR,
MODEL SMALL 2xJT!lN
IDEAL ~!G&K`u
STACK 100H q*kieqG
SjRR8p<
DATASEG !&=%#i
HW DB 'Hello, world!$' A1u|L^
<1EmQ)B
CODESEG ~RS^Opoa
MOV AX, @data H%:u9DlEK/
MOV DS, AX <(<19t5 .
MOV DX, OFFSET HW B%e#u.'6
MOV AH, 09H %M_5C4&6
INT 21H <0hJo=6a8
MOV AX, 4C00H uY5Gn.Y
INT 21H ;n-IpR#|
END /^>yDGT,0
c6NCy s
J@I-tS
x86 CPU,GNU/Linux,NASM 9v2(cpZ
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). [Y^1}E*
;Enter this into "hello.asm" then type: }:5>1FfX=
;"nasm -f elf hello.asm" ;*8nd-\
;"ld hello.o -o hello" !Ho=(6V
;"./hello" mp x/~`c
Q(e 3-a
section .data ;data section declaration 0Q_@2
msg db 'Hello World!',0AH yt-F2Z&
len equ $-msg ;string length wc
!
v /A
LbeMP
section .text ;code section declaration )5M9Ro7
global _start ;entry point (start of execution) /`Wd+
_start: mov edx,len ;string length Hx]{'?
mov ecx,msg ;string start .+"SDtoX
mov ebx,1 ;file handle: stdout T'TxC)
mov eax,4 ;sys_write s`$px2Gw
int 80h ;kernel system call -}?ud3f<
tt7l%olw
mov ebx,0 ;return value 4gNF;
mov eax,1 ;sys_exit .C2.j[>
int 80h ;kernel system call \I4*|6kA
;_ ^"}
Y=6b oT
x86 CPU,Windows,MASM32 K)`\u7Bu
.386 L,F )l2
.model flat,stdcall %Jr6pmc
option casemap:none = +uUWJ&1G
;Include 文件定义 ?+bDFM}
include windows.inc Wo^r#iRko
include user32.inc vG<JOxP
includelib user32.lib >iCkvQ
include kernel32.inc sO!YM5v8
includelib kernel32.lib Bi+a)_K
;数据段 W,^(FR.
.data uW,L<