“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 %}unlSTPP
e0IGx]5i
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 h;mOfF
3@* ~>H
以下是用不同语言写成的Hello World程序的几个例子: Iz&d
S?p_
Ada ?"kU+tCxg
with Ada.Text_Io; use Ada.Text_Io; =@nW;PUZ
procedure Hello is G0Z$p6z
begin s !II}'Je
Put_Line ("Hello, world!"); s"~,Zzy@j
end Hello; 4C3i
u,~+ho@
^ '_Fd
汇编语言 a(uQGyr[k1
?OGs+G
x86 CPU,DOS,TASM IvI;Q0E-3
MODEL SMALL Z/:W.*u
IDEAL $4kbOqn4
STACK 100H ^P`I"T
d
<
B!f;
DATASEG waG &3m
HW DB 'Hello, world!$' DLO#_t^v.
)i:"cyoE
CODESEG y,c\'}*H
MOV AX, @data ZIc-^&`r=
MOV DS, AX g^U-^f
MOV DX, OFFSET HW w1
A-_
MOV AH, 09H }IQ! [T5
INT 21H [geT u
MOV AX, 4C00H |7.X)h`
INT 21H Z*(OcQ-
END bNoZ{ 7
gL1r"&^L
ObataUxQT
x86 CPU,GNU/Linux,NASM Ko
"JH=<
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). 2]r5e;
;Enter this into "hello.asm" then type: TLg 9`UA
;"nasm -f elf hello.asm" GT3}'`f B
;"ld hello.o -o hello" m-qOyt
;"./hello" CljEC1S#
9gZS)MZ
section .data ;data section declaration !_?HSDAj"n
msg db 'Hello World!',0AH }(WUZ^L
len equ $-msg ;string length 5UQ[vHMqI
@Q:?,
section .text ;code section declaration #Zn+-Ih
global _start ;entry point (start of execution) .SBN^fq
_start: mov edx,len ;string length dhuIVBp!!e
mov ecx,msg ;string start T <RWz
mov ebx,1 ;file handle: stdout Iapzh y2l
mov eax,4 ;sys_write >_X(rar0
int 80h ;kernel system call wHQYBYKcd
z] |Y
mov ebx,0 ;return value qLB(Th\&'
mov eax,1 ;sys_exit /#}%c'
int 80h ;kernel system call T n,Ifo3
2XeN E[
7f~7vydZ}
x86 CPU,Windows,MASM32 MF$NcU
.386 P[e#j
.model flat,stdcall /FcwsD\=$
option casemap:none r?`7i'
;Include 文件定义 u;8bbv4
include windows.inc [VouG{
include user32.inc x/ P\qI
includelib user32.lib D.h <!?E%
include kernel32.inc {[+Q\<