“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 ku&k'V
@%ECj)u`O
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 )%Iv[TB[
_e<o7Y@_
以下是用不同语言写成的Hello World程序的几个例子: T6BFX0$
Ada A#y@`}]!'
with Ada.Text_Io; use Ada.Text_Io; r ,(Mu
procedure Hello is 8p^B hd
begin H`QQG!
Put_Line ("Hello, world!"); D-p.kA3MJ
end Hello; 5Rv+zQ#GR
N"7]R[*
t0E 51Ic@
汇编语言 0\QR!*'$
nms8@[4-
x86 CPU,DOS,TASM QG
gF|c7
MODEL SMALL A;X=bj _&a
IDEAL 45 >XKr.%
STACK 100H ['qnn|
:$r ^_
DATASEG YA]5~ZE\
HW DB 'Hello, world!$' HL K@xKD<
_8?o'<!8?^
CODESEG =r.
>N\
MOV AX, @data /F/;G*n
MOV DS, AX S~OhtHwK
MOV DX, OFFSET HW E /<lGm:.
MOV AH, 09H 3R$Z[D-
INT 21H 'Prxocxq
MOV AX, 4C00H Ri*3ySyb
INT 21H 2[yBD-":
END N:5[,O<m_
|UUdz_i!:
P5<vf
x86 CPU,GNU/Linux,NASM aoW6U{\
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). <yUstz,Xu^
;Enter this into "hello.asm" then type: v
$({C
;"nasm -f elf hello.asm" KA s 1(oG
;"ld hello.o -o hello" \3YO<E!t
;"./hello" ~.g3ukt
8MwK.H[U
section .data ;data section declaration ts~{w;c
msg db 'Hello World!',0AH ?\=/$Gt
len equ $-msg ;string length >!6JKL~=
NZLAk~R;0
section .text ;code section declaration BRRj$)u
global _start ;entry point (start of execution) Qx3eLfm
_start: mov edx,len ;string length \%jVg\4'
mov ecx,msg ;string start ,\)a_@@k
mov ebx,1 ;file handle: stdout 2h=%K/hhY
mov eax,4 ;sys_write j7QX,_Q
int 80h ;kernel system call ?uL eFD
uzr\oj+>
mov ebx,0 ;return value k=ytuV\
mov eax,1 ;sys_exit Zo-$z8
int 80h ;kernel system call >h~IfZU1
je,}_:7
= "ts`>
x86 CPU,Windows,MASM32 +a@GHx4-
.386 %|W.^q
.model flat,stdcall l ,|%7-
option casemap:none a6xj\w
;Include 文件定义 7*+]wEs
include windows.inc >p\e0n
include user32.inc )(M7lq.e7
includelib user32.lib &]6)LFm
include kernel32.inc gxNL_(A
includelib kernel32.lib <=K qcHb
;数据段 6 ,ANNj
.data _u0$,Y?&