“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 _p+q)#.W
&#]||T-
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 wqXo]dX
u,@x7a,z
以下是用不同语言写成的Hello World程序的几个例子: @Z~0!VY
Ada _ 1\H{x
with Ada.Text_Io; use Ada.Text_Io; fhQ N;7
procedure Hello is >P ygUY
d
begin TrHUM4
Put_Line ("Hello, world!"); w:9n/[
end Hello; t\<*Q3rl-
?kc,}/4
-EU~
%/=m+
汇编语言 ZpU4"x>
G9>
0w)r
x86 CPU,DOS,TASM 9kU|?JE
MODEL SMALL k%cT 38V*
IDEAL [-Mfgw]i
STACK 100H RXbZaje$
]<E\J+5K
DATASEG n11eJEtm
HW DB 'Hello, world!$' }Q>??~mVl
HBgt!D0MZ
CODESEG 6q^.Pg-Y
MOV AX, @data zDA;FKZPp
MOV DS, AX >K;C?gHo
MOV DX, OFFSET HW {UEZ:a
MOV AH, 09H e%&/K7I "?
INT 21H
0GiL(e|
MOV AX, 4C00H
]4oF!S%F
INT 21H ,O"zz7
END ob>2SU[Y
c
]&|.~2 &
q \\52:\
x86 CPU,GNU/Linux,NASM UR.l*+<W7
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). Ps7Bt(/
;Enter this into "hello.asm" then type: L[ 7Aa"R
;"nasm -f elf hello.asm" @{UtS2L
;"ld hello.o -o hello" ^T/d34A;SP
;"./hello" /*{s1Zcb
Ea[K$NC)#
section .data ;data section declaration OX)[?1m8
msg db 'Hello World!',0AH |B.tBt^
len equ $-msg ;string length XQL]I$?
c4n]#((%a
section .text ;code section declaration +}0/ %5 =1
global _start ;entry point (start of execution) 2AI~Jm#
_start: mov edx,len ;string length 6N'v`p8
mov ecx,msg ;string start '\.fG\xD
mov ebx,1 ;file handle: stdout ,XNz.+Ov
mov eax,4 ;sys_write ey>V^Fj
int 80h ;kernel system call zHvG3Ed@
=7uxzg/%Tj
mov ebx,0 ;return value o72G oUfs
mov eax,1 ;sys_exit -*Z;EA-
int 80h ;kernel system call ohe0}~)V
StJ&YYdD
c:MP^PWc
x86 CPU,Windows,MASM32 #Y;_W;#
.386 ?4,e?S6,[
.model flat,stdcall Dy_Za.N2
option casemap:none eE/E#W8
;Include 文件定义 L<**J\=7M
include windows.inc 1FiFP5
include user32.inc 8Yq_6
includelib user32.lib }&OgI