“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 <t)D`nY\
v{*#
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 DW.vu%j^[
{G(N vf,K]
以下是用不同语言写成的Hello World程序的几个例子: 6A*k
Ada vILq5iR
with Ada.Text_Io; use Ada.Text_Io; 3v7*@(y
procedure Hello is @>SirYh
begin o@blvW<v7
Put_Line ("Hello, world!"); CJ#1j>
end Hello; WwYy[3U
9#ZR0t.cY
Ph|\%P`>%
汇编语言 cuW&X9\m,
3CArUP
x86 CPU,DOS,TASM @"gWvs
MODEL SMALL 6;vfl*
IDEAL 9_<>#)u5
STACK 100H FT+[[9i
C
lekB
DATASEG Mo_(WSs
HW DB 'Hello, world!$' @O Rk
euc|G Xs
CODESEG % C.I2J`_
MOV AX, @data yp.\KLq8)
MOV DS, AX UA]U_P$c
MOV DX, OFFSET HW uf<nVdC.
MOV AH, 09H N)b.$aC
INT 21H 2#?qey
MOV AX, 4C00H l=?G"1
INT 21H CAvyS
END t>izcO
1#-=|:U
TSHQ>kP
x86 CPU,GNU/Linux,NASM ^P
!}"
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). K|g+Wt^tQ
;Enter this into "hello.asm" then type: fkmN?CU{1%
;"nasm -f elf hello.asm" 5$.e5y<&(
;"ld hello.o -o hello" i$:QOMA
;"./hello" M
h5>@-fEE
A9L
{c!|-
section .data ;data section declaration ofIw7D*h
msg db 'Hello World!',0AH RNB ha&
len equ $-msg ;string length jizp\%W+
B+8B<xZ
section .text ;code section declaration SWrP0Qjc
global _start ;entry point (start of execution) j`A 3N7;
_start: mov edx,len ;string length x\MzMQ#Bf
mov ecx,msg ;string start xgV(0H}Mf
mov ebx,1 ;file handle: stdout 0.}WZAYy~
mov eax,4 ;sys_write ygn]f*;?kw
int 80h ;kernel system call l'0fRQc
YD|;xuh
mov ebx,0 ;return value FyV)Nmc%t
mov eax,1 ;sys_exit WfF~\DlrD
int 80h ;kernel system call pNIu;1M5a
Tz{f5c&
{, `)
x86 CPU,Windows,MASM32 [c_o.`S_\
.386 />q?H)6
.model flat,stdcall 1so9w89
option casemap:none ;+-Dg3
;Include 文件定义 sF+Bu'9A
include windows.inc 5h6c W
include user32.inc y-i6StJ
includelib user32.lib m/(f?M l
include kernel32.inc Oj~4uT&"
includelib kernel32.lib MhXJ /bup
;数据段 >azTAX6L3
.data \Q m1+tg
szCaption db 'A MessageBox!',0 />,KWHR|:
szText db 'Hello,world!',0 9yt)9f
;代码段 PBo;lg`
.code qZz?i
start: ;H;c Sn5uL
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK RAps`)OR?
invoke ExitProcess,NULL 1o*eu&@
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> h~R= ?%H[
end start a(BEm_l3
S%t*!
^<