“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 cz2,",+~
&/s~? Iq
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 GAv)QZyV$
Bk@)b`WR
以下是用不同语言写成的Hello World程序的几个例子: 7p)N_cJD
Ada Bul.RCP'
with Ada.Text_Io; use Ada.Text_Io; k}D[Hp:m
procedure Hello is }>V/H]B
begin ~xS@]3n=
Put_Line ("Hello, world!"); 42fprt
end Hello; 6m9 7_NRO
!:(C"}5wM
8N%z9b
汇编语言 bA}Z0a
%y iD~&
x86 CPU,DOS,TASM oEJaH
MODEL SMALL cVp[ Z#B
IDEAL }2lO _i}L
STACK 100H *=Doe2(!C
Yx5J$!Ld
DATASEG q]px(
HW DB 'Hello, world!$' 0<g<GQ(E
YG4WS |
CODESEG GuT6K}~|D
MOV AX, @data 6O9iEc,HM
MOV DS, AX 20aZI2sk`
MOV DX, OFFSET HW 9 ~~qAoD
MOV AH, 09H tQrS3Hz'nA
INT 21H /}Yqf`CZy
MOV AX, 4C00H D9.`hs0
INT 21H s2%V4yy%
END ob
E:kNE9
4QE=f(u;h
|QVr`tE<
x86 CPU,GNU/Linux,NASM 'WQdr(
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). g<$. - g
;Enter this into "hello.asm" then type: bDDqaO ,8
;"nasm -f elf hello.asm" ocF>LR%P
;"ld hello.o -o hello" RvyuGU
;"./hello" ,h^r:g
o@9+mM"B)
section .data ;data section declaration >SoO4i8
msg db 'Hello World!',0AH O|I+],
len equ $-msg ;string length bKMWWJf*'
ZqQ*}l5
section .text ;code section declaration ~-_i
global _start ;entry point (start of execution) i5"5&r7r
_start: mov edx,len ;string length edijfhn
mov ecx,msg ;string start CvK3H\.&;k
mov ebx,1 ;file handle: stdout _({@B`N}
mov eax,4 ;sys_write hv>KX
int 80h ;kernel system call 6YmP[%
l4vTU=
mov ebx,0 ;return value nO{ x^b <
mov eax,1 ;sys_exit @vRwzc\
int 80h ;kernel system call 8[zb{PRu
bO3GVc+S
Z/<#n\>t0>
x86 CPU,Windows,MASM32 R>2I RvY(
.386
l{$[}<
.model flat,stdcall #y1Bx,
option casemap:none ~$<UE}qp
;Include 文件定义 _?`&JF