“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 QWp,(Mv:r
hiZE8?0+~N
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 eQbDs_
q90eB6G0g
以下是用不同语言写成的Hello World程序的几个例子: Mhc!v, D$
Ada ~ pWbD~aeg
with Ada.Text_Io; use Ada.Text_Io; QqA~y$'ut
procedure Hello is T0J"Wr>WY
begin M.iR5Uh
Put_Line ("Hello, world!"); {f3&s4xj=
end Hello; VHGOVH,
Hr |De8#f
l8/ tR
汇编语言 2 |
$
YKk?BQ"
x86 CPU,DOS,TASM c
%w
h
MODEL SMALL /ldE (!^n
IDEAL S\RjP*H*
STACK 100H %8NAWDb{
{p&LwTnf
DATASEG ^AS*X2y
HW DB 'Hello, world!$' gDU~hv
t84(k zcC
CODESEG 5-3`@ (/
MOV AX, @data ^tc2?T
MOV DS, AX 5}@6euT5$
MOV DX, OFFSET HW -`x$a&}
MOV AH, 09H JY8wo 5H
INT 21H .]}kOw:(#
MOV AX, 4C00H {1,]8!HBJ
INT 21H m{4e+&S|
END L8("1_
0h nTHlk
{_ti*#
x86 CPU,GNU/Linux,NASM %T4htZa
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). b1Bu5%bt,:
;Enter this into "hello.asm" then type: b0|q@!z>
;"nasm -f elf hello.asm" i>#[*.|P
;"ld hello.o -o hello" m`l3@Z
;"./hello" ]@)T]
>Ng7q?h
section .data ;data section declaration ^_BHgbS%;
msg db 'Hello World!',0AH JfS:K'
len equ $-msg ;string length )y&}c7xW
&"]Uh
section .text ;code section declaration (ds-p[`[m
global _start ;entry point (start of execution) *)+1BYMo
_start: mov edx,len ;string length lX$6U|!
mov ecx,msg ;string start 3#o!K
mov ebx,1 ;file handle: stdout s\A"B#9r
mov eax,4 ;sys_write F[uy'~;@
int 80h ;kernel system call |y=; #A
W!|A3V35\:
mov ebx,0 ;return value pcwkO
mov eax,1 ;sys_exit R
L&z\S
int 80h ;kernel system call -7\Rl3c
SEsc"l8
ENW>bS8e`
x86 CPU,Windows,MASM32 "X4L+]"$g
.386 EooQLZ
.model flat,stdcall p""#Gbwj
option casemap:none (%*CfR:>
;Include 文件定义 v3SH+Ej4
include windows.inc 6) {jHnk)
include user32.inc AW3\>WC
includelib user32.lib QB p`r#{I{
include kernel32.inc <>\s#Jf/
includelib kernel32.lib P F5;2
;数据段 Ba==Ri8$
.data Gh;Ju[6
szCaption db 'A MessageBox!',0 C;7?TZ&x