“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 \=3fO(
E{):zg
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 `E @TPdu
WF'Di4
以下是用不同语言写成的Hello World程序的几个例子: 8-f2$
Ada m+jW+
with Ada.Text_Io; use Ada.Text_Io; 0uw3[,I
procedure Hello is pwu8LQ3b{O
begin bcVzl]9
Put_Line ("Hello, world!"); #$W bYL|
end Hello; -#TF&-
-XbO[_Wf
f( %r)%
汇编语言 5V"Fy&}:
s":\>
x86 CPU,DOS,TASM 5eP0W#
MODEL SMALL } `X.^}oe
IDEAL ~8rVf+bg3
STACK 100H VG)Y$S8.>
t<UtSkE1
DATASEG !)!<.x
HW DB 'Hello, world!$' y2_^lW%
Or({|S9d2
CODESEG {? a@UUvC
MOV AX, @data l(o;O.dLt
MOV DS, AX %.NOQ<@W
MOV DX, OFFSET HW ITUwIpAE
MOV AH, 09H :)djHPP*
INT 21H kdr?I9kwW
MOV AX, 4C00H ('9LUFw\
INT 21H >Rnj6A|Q
END E/<5JhI9~
:o2^?k8k
bVLuv`A/
x86 CPU,GNU/Linux,NASM ~|FKl%
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). *8WcRx
;Enter this into "hello.asm" then type: vk^ /[eha
;"nasm -f elf hello.asm" 7KB:wsz^
;"ld hello.o -o hello" h2Kx
;"./hello" /4Df 'd
5O7x4bY
section .data ;data section declaration PkqOBU*|=
msg db 'Hello World!',0AH \G+uK:PC,
len equ $-msg ;string length +nLsiC{&
RhL!Zz
section .text ;code section declaration Vm3e6Y,K
global _start ;entry point (start of execution) AV t(e6H
_start: mov edx,len ;string length WNE=|z#|
mov ecx,msg ;string start \[!k`6#t7
mov ebx,1 ;file handle: stdout "Z\^dR
mov eax,4 ;sys_write `1 tD&te0
int 80h ;kernel system call xs'vd:l.Pp
!awsQ!e|
mov ebx,0 ;return value !yfQ^a_O
mov eax,1 ;sys_exit sF+mfoMtG
int 80h ;kernel system call >$%rs c}^
>k\lE(
.b3cn
x86 CPU,Windows,MASM32 v ?9
.386 e>FK5rz
.model flat,stdcall UNc[h&@_
option casemap:none nMBKZ
;Include 文件定义 qjtrU#n
include windows.inc
C0Oe$&
_
include user32.inc G"xa"hGF
includelib user32.lib EYLqg`2A
include kernel32.inc 6)@Y 41H]C
includelib kernel32.lib 4a]$4LQV
;数据段 ~EV7E F
.data xe=/T#%
szCaption db 'A MessageBox!',0 Lwy9QZL
szText db 'Hello,world!',0 P
~sX S
;代码段 xUKn
.code nc0!ag
start: A3;}C+K
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK jTDaW8@L
invoke ExitProcess,NULL 52zD!(
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> szDd!(&pv
end start L{2KK]IF
3T<aGW1
RV&