“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 ?|}qT05
<}c7E3Uc
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 %BMlcm7Ec
:f_oN3F p
以下是用不同语言写成的Hello World程序的几个例子: #uC}IX2n
Ada %z-s o?gF
with Ada.Text_Io; use Ada.Text_Io; -byaV;T?"
procedure Hello is hgDFhbHtd6
begin >o&%via}
Put_Line ("Hello, world!"); ?8< =.,r
end Hello; I0x;rP
S5Pn6'w
y@2"[fo3~
汇编语言 g`.H)36
~ oq.y n/1
x86 CPU,DOS,TASM hBaG*J{
MODEL SMALL {-]K!tWda
IDEAL H,GnF
STACK 100H N:#$S$
QGGBI Ku
DATASEG Vu4LC&q
HW DB 'Hello, world!$' ePaC8sd0
U#PgkP[4
CODESEG
Fe$o*r,
MOV AX, @data ]-a/)8
MOV DS, AX G-]<+-Q$4
MOV DX, OFFSET HW u}_x
MOV AH, 09H C8)s6
INT 21H ni )G
MOV AX, 4C00H tux`-F
INT 21H "A~D(1K
END =JPY{'V O
on5\rY<I:@
SJ;{ Hg
x86 CPU,GNU/Linux,NASM _F4=+dT|
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). \'('HFr,
;Enter this into "hello.asm" then type: ~d,$nZ"z
;"nasm -f elf hello.asm" tO1k2<Z"Y&
;"ld hello.o -o hello" 4 CiRh
;"./hello" /!6 VP |
H0t#J
section .data ;data section declaration 4 2,dHYdt
msg db 'Hello World!',0AH u% 1JdEWZd
len equ $-msg ;string length Yb[)ETf^
~+Cl9:4T
section .text ;code section declaration rTJqw@]#WH
global _start ;entry point (start of execution) IeA/<'Us
_start: mov edx,len ;string length Ro<5c_k
mov ecx,msg ;string start L>hLYIW
mov ebx,1 ;file handle: stdout };Df ><
mov eax,4 ;sys_write 7`)RBhGB
int 80h ;kernel system call 3|)cT1ej
\S?-[v*{
mov ebx,0 ;return value fT?m~W^
mov eax,1 ;sys_exit > hGB
o
int 80h ;kernel system call w_~tY*IwB
=1)9>= }
asy:[r"
x86 CPU,Windows,MASM32 zA$ f$J7\^
.386 ]y$/~(OW
.model flat,stdcall GN5*
option casemap:none %=s2>vv9
;Include 文件定义 P+_1*lOG
include windows.inc VtU2&
include user32.inc M-+!z5q~d
includelib user32.lib *qm>py`O
include kernel32.inc =dQF}-{!
includelib kernel32.lib P9S)7&+DL
;数据段 gd7!+6
.data dPV<:uO
szCaption db 'A MessageBox!',0 5*90t{#
szText db 'Hello,world!',0 mT|r:Yr:
;代码段 .+u r+"i
.code QMX
start: #BH]`A J
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK X_rv}
invoke ExitProcess,NULL H3iYE~^#
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> h+YPyeAs
end start '*&V7:
wLE|J9t%Ea
W>b\O">
AWK v=&xiw