“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 PnlI {d
IK~&`n](>
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 0YeTS!*Aj
-N *L1Zj
以下是用不同语言写成的Hello World程序的几个例子: EY}:aur
Ada }aCa2%
with Ada.Text_Io; use Ada.Text_Io; #YUaM<O
procedure Hello is 1<@SMcj>
begin M `xiC
Put_Line ("Hello, world!"); gv#\}/->4
end Hello; Y+gY"
3a/n/_D
Y.tx$%
汇编语言 d:H'[l.F%
l'@-?p(Vuw
x86 CPU,DOS,TASM VJh8`PVX
MODEL SMALL e~'`x38
IDEAL jN=<dq
~
STACK 100H P&-o>mM
Yo-}uTkw
DATASEG H=t"qEp
HW DB 'Hello, world!$' ]S|FK>U[
Xlo7enzY
CODESEG wb-yAQ8
MOV AX, @data 5of3&
MOV DS, AX zM0NRERi
MOV DX, OFFSET HW =W(*0"RM
MOV AH, 09H B5e9'X^
[
INT 21H sE1cvAw9l
MOV AX, 4C00H 4ls:BO;k]
INT 21H *6uccx7{
END Dn- gP
"tK%]c d-
p 7?
x86 CPU,GNU/Linux,NASM &y[NCAeA
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). p7h#.m~Qu
;Enter this into "hello.asm" then type: WWT1= #"
;"nasm -f elf hello.asm" EeIDlm0o
;"ld hello.o -o hello" }\pI`;*O|
;"./hello" P T"}2sR)
tF2"IP.
section .data ;data section declaration ~5 ^Jv m
msg db 'Hello World!',0AH N^^0j,
len equ $-msg ;string length 9g9 2eKS
|(7}0]BP0
section .text ;code section declaration xQy,1f3s+
global _start ;entry point (start of execution) 'J|2c;M\x
_start: mov edx,len ;string length
B.z$0=b
mov ecx,msg ;string start %+7]/_JO&