“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 |tP1,[w">
2/RK
pl &
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 L,of@>
O?p.kf{b
以下是用不同语言写成的Hello World程序的几个例子: F IDNhu
Ada )fP,F(
with Ada.Text_Io; use Ada.Text_Io; zh2$U
dZ|M
procedure Hello is Jg/l<4,K,
begin zNuiBLxDs
Put_Line ("Hello, world!"); h ^g"FSzP
end Hello; X0^gj>GI|
n=MdbY/k(
*Af]?-|^{#
汇编语言 2x{@19w)C
eft-]c+*0
x86 CPU,DOS,TASM Kg=TPNf"$
MODEL SMALL Bs =V-0
IDEAL ,WR$xi.j
STACK 100H @y[Zr6\z
>~_y\
DATASEG }]>[FW
HW DB 'Hello, world!$' -20o%t
L7_(KC h
CODESEG 9*GwW&M%1_
MOV AX, @data vnMt>]w-}
MOV DS, AX !I-+wc{ss
MOV DX, OFFSET HW ~`
@dI
MOV AH, 09H 6%H8Qv
INT 21H N(vzxx^
MOV AX, 4C00H x9xb4ZW
INT 21H D-9zg\\'`
END 7Gnslp?[U
QG?7L_I
2!\y0*}K
x86 CPU,GNU/Linux,NASM m(q6Xe:Vc
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). L!V`Sb
;Enter this into "hello.asm" then type: 3H%R`ha
;"nasm -f elf hello.asm" j WLZ!a3+
;"ld hello.o -o hello" Bwjd/id q
;"./hello" qF`;xa%,}
!CtY.Lp
section .data ;data section declaration Ziuf<X{
msg db 'Hello World!',0AH nQdNXv<(
len equ $-msg ;string length zT#36+_?
V9-pY/v9
section .text ;code section declaration E:V&:9aQ@
global _start ;entry point (start of execution) !H{)L@f
_start: mov edx,len ;string length Msn)jh
mov ecx,msg ;string start <*0MD6$5
mov ebx,1 ;file handle: stdout 7Ro7/PT(
mov eax,4 ;sys_write UBOCd[
int 80h ;kernel system call OMd{rH
Q-F'-@`(C
mov ebx,0 ;return value jV\M`=4IC
mov eax,1 ;sys_exit ;!, ]}2w*X
int 80h ;kernel system call OHssUt
fU@}]&
~'dnrhdme
x86 CPU,Windows,MASM32 LTp5T|O
.386 <4bv=++pS
.model flat,stdcall Ictc '#y
option casemap:none b<