“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 ,}%+5yH
$0rSb0[
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 ;5tSXgGw7
D@T>z;
以下是用不同语言写成的Hello World程序的几个例子: AtNu:U$
Ada e-Z+)4fH
with Ada.Text_Io; use Ada.Text_Io; #&vP(4p
procedure Hello is Yrp
WGK520
begin qv<[f=X9|
Put_Line ("Hello, world!"); oy90|.]G
end Hello; 3{o5AsVv
+JE
h7
<6k5nE h
汇编语言 ol^J-
P@LYa_UFsN
x86 CPU,DOS,TASM V[>MKB(
MODEL SMALL Y=JfV
IDEAL (hTe53d<S?
STACK 100H o$I% 1
&-#!]T-P:E
DATASEG <_&H<]t%rI
HW DB 'Hello, world!$' Y>z~0$
kDuN3
CODESEG il=y m
MOV AX, @data F0
WM&{v
MOV DS, AX |]`\ak
MOV DX, OFFSET HW oGpyuB@A/
MOV AH, 09H wJA`e)>
INT 21H DZGM4|@<7Y
MOV AX, 4C00H -E1b5i;f
INT 21H O)|{B>2r
END &d]%b`EXq
+rS}f
N$L.
lb3: #?
x86 CPU,GNU/Linux,NASM gE^
{@^
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). \4y7!
;Enter this into "hello.asm" then type: [ h7nOUL!
;"nasm -f elf hello.asm" |- 39ZZOX
;"ld hello.o -o hello" qX[a\HQa
;"./hello" 4[t1"s~Wg
COJny/FT|
section .data ;data section declaration f]H[uzsV
msg db 'Hello World!',0AH iTi]D2jC
len equ $-msg ;string length `Y`Ujr\6
n2\;`9zm
section .text ;code section declaration _SM5x,Zd
global _start ;entry point (start of execution) 7a.$tT
_start: mov edx,len ;string length &6nOCU)
mov ecx,msg ;string start &VtTUy}
mov ebx,1 ;file handle: stdout Uu xbN-u
mov eax,4 ;sys_write , Z*Fo: q
int 80h ;kernel system call o|lEF+
[eI{vH{
mov ebx,0 ;return value Y3G$(+i8
mov eax,1 ;sys_exit ]MJyBz+k
int 80h ;kernel system call JgXP2|Y !
Ld>y Fb(`
n@[&SgZq
x86 CPU,Windows,MASM32 <oG+=h
.386 q6'3-@%
.model flat,stdcall NqcmjHvy
option casemap:none WT$m*I
;Include 文件定义 i8A{DMc,U
include windows.inc MJS4^*B\1
include user32.inc p$^}g:
includelib user32.lib VR/7CI4=
include kernel32.inc +grIw#j
includelib kernel32.lib FHWzwi*u}
;数据段 T4n.C~
.data !$r4 lu
szCaption db 'A MessageBox!',0 $PA=7`\MP/
szText db 'Hello,world!',0 ;Hr
FPx&d1
;代码段 |UvM[A|+
.code 37'@,*m`
start: 6#P\DT
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK jH26-b<
invoke ExitProcess,NULL ,Oojh;P_
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> &