“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 cruBJZr*
9v;HE{>
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 XjP&
/#SfgcDt
以下是用不同语言写成的Hello World程序的几个例子: 9_F&G('V{a
Ada ]7>#YKH.
with Ada.Text_Io; use Ada.Text_Io; l6 }+,v@#
procedure Hello is f~PS'I_r
begin 7R
m\#
Put_Line ("Hello, world!"); GDe,n
end Hello; UKV<Ye|
x?lRObHK
WT")tjVKA
汇编语言 _|cSXZ|
4o;;'P
x86 CPU,DOS,TASM k;`1Ia
MODEL SMALL 85)C7tJ-g
IDEAL 6<>1,wbq
STACK 100H }{j@q~w>$
Mis B&Ok`k
DATASEG r@]`#PL
HW DB 'Hello, world!$' ,x!r^YO=
FG+pR8aA$
CODESEG 7I#C[:7x
MOV AX, @data !g6=/9
MOV DS, AX mMOgx
MOV DX, OFFSET HW XP0;Q;WF}
MOV AH, 09H R@s|bs?
INT 21H i+in?!@G:
MOV AX, 4C00H s$qc&
INT 21H q
:~/2<o
END je2"D7D
Lu:*nJ%1[
.0RQbc9
x86 CPU,GNU/Linux,NASM W)J5[p?
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). nxBP@Td
;Enter this into "hello.asm" then type: [tJn!cMs
;"nasm -f elf hello.asm" u-s*k*VHoc
;"ld hello.o -o hello" ,}@4@ >?K
;"./hello" #NGtba
On~KTt3Mp
section .data ;data section declaration WcS`T?Xa
msg db 'Hello World!',0AH )8rF'pxI
len equ $-msg ;string length o _l_Yi
}CMGK{
section .text ;code section declaration ZzTkEz >
global _start ;entry point (start of execution) zh0T3U0D
_start: mov edx,len ;string length >o{JG(Rn
mov ecx,msg ;string start F[%k;aJ
mov ebx,1 ;file handle: stdout \P9ms?((A
mov eax,4 ;sys_write =)c-Xz
int 80h ;kernel system call }uC]o@/
3.hFYA w
mov ebx,0 ;return value Ayg^<)JWh
mov eax,1 ;sys_exit SCe$v76p#
int 80h ;kernel system call r-xP6
lw}7kp4
2F
@x}^2FE
x86 CPU,Windows,MASM32 G~bDl:k`A
.386 nw+^@|4
.model flat,stdcall C96*,.j~'
option casemap:none p=A,yGDV
;Include 文件定义 7RBEEE`)
include windows.inc (3D&