“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 %BQ?DTtb7'
U*XdFH}vV
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 <[=[|DS l
8C*xrg#g:
以下是用不同语言写成的Hello World程序的几个例子: iH>b"H>
Ada s~k62
with Ada.Text_Io; use Ada.Text_Io; UG]x CkDS
procedure Hello is uWi pjxS
begin 99n;%W>
Put_Line ("Hello, world!"); M0hR]4T
end Hello; g!i45]6[Nw
Z%
]LZ/O8
%}unlSTPP
汇编语言 }H/94]~tH
e0IGx]5i
x86 CPU,DOS,TASM QBA{*@ A-
MODEL SMALL Z{2QDjAI;
IDEAL }4Q3S1|U
STACK 100H X @/X65=[
,V)hV@Dk
DATASEG /K;A bE
HW DB 'Hello, world!$' Fxn=+Xgg
gx2v(1?S
CODESEG AjsjYThV
MOV AX, @data CY"i|s
MOV DS, AX JB!*{{
MOV DX, OFFSET HW xXJzE|)1h!
MOV AH, 09H M>i *e
INT 21H u3DFgl3-7
MOV AX, 4C00H (l/i#
INT 21H }a%Wu 7D
END kmt+E'^]
4$4Tx9C
S+?*l4QK
x86 CPU,GNU/Linux,NASM fT=ZiHJ3Gu
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). I/gfsyfA
;Enter this into "hello.asm" then type: 7,Q7`}gBf
;"nasm -f elf hello.asm" ,t|_Nc
;"ld hello.o -o hello" H~:g=Zw
;"./hello" V'9OGn2v
slLTZ]
section .data ;data section declaration xscR Bx
msg db 'Hello World!',0AH I]~s{I(EK
len equ $-msg ;string length |1Nz8Vr.
^5+7D1>W%
section .text ;code section declaration iphdJZ/f
global _start ;entry point (start of execution) %v^qQWy=*
_start: mov edx,len ;string length k"cKxzB
mov ecx,msg ;string start yK mHTjX=
mov ebx,1 ;file handle: stdout 3Q,p,
mov eax,4 ;sys_write McN'J.Sxp
int 80h ;kernel system call Rli`]~!w
#t
VGqf
mov ebx,0 ;return value 9gZS)MZ
mov eax,1 ;sys_exit !_?HSDAj"n
int 80h ;kernel system call z[JM ]Wy
}(WUZ^L
5UQ[vHMqI
x86 CPU,Windows,MASM32 OQDx82E
.386 #Zn+-Ih
.model flat,stdcall .SBN^fq
option casemap:none dhuIVBp!!e
;Include 文件定义 uuy0fQQ8ti
include windows.inc Iapzh y2l
include user32.inc >_X(rar0
includelib user32.lib wHQYBYKcd
include kernel32.inc z] |Y
includelib kernel32.lib qLB(Th\&'
;数据段 /#}%c'
.data 7/\SN04l
szCaption db 'A MessageBox!',0 / $'M
szText db 'Hello,world!',0 ])WIw'L!
;代码段 2 xi@5;!
.code W#^p%?8pR
start: ?MiMwVR
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK u7-0?
invoke ExitProcess,NULL 5jTA6s9z A
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [U7r>&