“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 #3u8BLy$Q
Q1eiU Y6
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 o}WbW }&
3L>V-RPi M
以下是用不同语言写成的Hello World程序的几个例子: aeUm,'Y$
Ada JpS:}yyJ>N
with Ada.Text_Io; use Ada.Text_Io; Pn 7oQA\
procedure Hello is d:sUh
begin Gq-U}r
Put_Line ("Hello, world!"); t4s}w$4
end Hello; wm2Q(l*HH
(nda!^f_s
jIdhmd* $z
汇编语言 (:T~*7/"
Kq!n`@
x86 CPU,DOS,TASM DU1,i&(
MODEL SMALL ` S85i*
IDEAL mg >oB/,'Z
STACK 100H sFS_CyN!7
zP=J5qOZ8
DATASEG bk4%lYJ"
HW DB 'Hello, world!$' SKRD{MRsux
]s,T`
(&
CODESEG >b*Pd
*f
MOV AX, @data |Ca$>]?
MOV DS, AX {8I93]
MOV DX, OFFSET HW 2?-}(F;Z
MOV AH, 09H ol`]6"Sc
INT 21H ^Gs!" Y
MOV AX, 4C00H kf5921(P
INT 21H PrN?;Z.
END HM[BFF[;/
7^Onq0ym T
@~gz-l^$
x86 CPU,GNU/Linux,NASM W=)}=^N0
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). m5d;lrk@&/
;Enter this into "hello.asm" then type: ~=c^Oo:
;"nasm -f elf hello.asm" 9pjk3a
;"ld hello.o -o hello" @RaMO#
;"./hello" wp*;F#: G
SZwfYY!ft0
section .data ;data section declaration 0W=IuPDU
msg db 'Hello World!',0AH c yN_Sg
len equ $-msg ;string length f$WO{J
C t SAo\F
section .text ;code section declaration Vl9\&EL
global _start ;entry point (start of execution) PVtQ&m$y
_start: mov edx,len ;string length &a