“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 qrkT7f
v+G:,Tc"
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 4Rn i7qH
}NXESZYoi
以下是用不同语言写成的Hello World程序的几个例子: 2~<0<^j/]
Ada _biJch
with Ada.Text_Io; use Ada.Text_Io; D/WS
procedure Hello is {JgN^R<5<f
begin OOCeZ3yF(
Put_Line ("Hello, world!"); kWd'gftQ
end Hello; DbN'b(+
Q [{vU
F*4+7$E0B
汇编语言 E'G>'cW;x
=-qsz^^a-
x86 CPU,DOS,TASM /HRaX!|E#
MODEL SMALL x_K%
IDEAL ~ #CCRUhM
STACK 100H J (h>
1 GdD
DATASEG Q
Y'-]
HW DB 'Hello, world!$' I,eyL$x
DtZm|~)a
CODESEG q1y4B`
MOV AX, @data "ivqh{ ,
MOV DS, AX P]B#i1
MOV DX, OFFSET HW Os{qpR^<I:
MOV AH, 09H hgK=fHJk
INT 21H 4B`Rz1QBy
MOV AX, 4C00H MQ44uHJ
INT 21H 5qy}~dQ
END kR|y0V {K*
eW0=m:6
/Hmo!"W`
x86 CPU,GNU/Linux,NASM ?=kswf
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). *-_Npu6
;Enter this into "hello.asm" then type: Qx;A; n!lw
;"nasm -f elf hello.asm" 7o. 'F
;"ld hello.o -o hello" 3U)8P6Fz
;"./hello" }El_.@'T &
!U_L7
section .data ;data section declaration l i-YkaP
msg db 'Hello World!',0AH O 0#Jl8
len equ $-msg ;string length 9f,:j
YW<2:1A|
section .text ;code section declaration F6p1 VFs
global _start ;entry point (start of execution) {%{GZ
_start: mov edx,len ;string length cAS_?"V
a
mov ecx,msg ;string start 0K ?(xB
mov ebx,1 ;file handle: stdout YHYB.H)
mov eax,4 ;sys_write {O)&5
int 80h ;kernel system call W#j,{&KVn
@3YuV=QfH
mov ebx,0 ;return value U[l%oLra
mov eax,1 ;sys_exit ItADO'M
int 80h ;kernel system call l #Q`f.
7h1gU
fh#_Mj+y
x86 CPU,Windows,MASM32
#Uh 5tc
.386 "ux]kfoT
.model flat,stdcall AvZ) 1(
option casemap:none Wg^cj:&`u
;Include 文件定义 )/"7$2Aoy
include windows.inc &F_rg,q&_
include user32.inc 31& .Lnq
includelib user32.lib u9w&q^0dqG
include kernel32.inc Kdu\`c-lB
includelib kernel32.lib 8F`
;数据段 *K'ej4"u
.data 2p>SB/
szCaption db 'A MessageBox!',0 OL5HofgNm
szText db 'Hello,world!',0 5Q` n6 x|
;代码段 `aL|qyrq#
.code KVxb"|[
start: /T)n5X
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK acQNpT
invoke ExitProcess,NULL ;
,jLtl
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ~qxXou,J
end start Y&