“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 .KLuGb3JJ
5.E 2fX
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 >k jJq]A2
S\rfR N
以下是用不同语言写成的Hello World程序的几个例子: ;lEiOF+d
Ada +=8Po'E^!d
with Ada.Text_Io; use Ada.Text_Io; x}[` -
procedure Hello is 6qDD_:F
begin NNdS:(
Put_Line ("Hello, world!"); #e=^[E-yE
end Hello; !58JK f
~S6N'$^
CYu8J@(\~g
汇编语言 %G
SSy_c
wz#n$W3mGf
x86 CPU,DOS,TASM e+WVN5"ID>
MODEL SMALL )5v .9N6v
IDEAL cA\W|A)
STACK 100H l{AT)1;^
;Vy'y
DATASEG 0Q9OQqg
m
HW DB 'Hello, world!$' Uwk|M?94
LN^8U
CODESEG 0A9cu,ZdUR
MOV AX, @data ~e8n yB
MOV DS, AX m>!#}EJ|
MOV DX, OFFSET HW el%Qxak`"
MOV AH, 09H sJlKN
INT 21H A%O#S<sa
MOV AX, 4C00H E=QQZ\w
INT 21H (Vv]:Y]
END /0uinx
eH8.O
jYF3u0
)
x86 CPU,GNU/Linux,NASM 5=986ci$U
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). AVWrD[ wD2
;Enter this into "hello.asm" then type: IA4(^-9
;"nasm -f elf hello.asm" 4#9-Z6kOk
;"ld hello.o -o hello" jg8P4s
;"./hello" n58jB:XR(
\#r_H9&s6
section .data ;data section declaration `ahXn
msg db 'Hello World!',0AH {;/o4[jlg
len equ $-msg ;string length )]R?v,9*D
tK
H!xit
section .text ;code section declaration B$Z!E%a;
global _start ;entry point (start of execution) -*2X YTe
_start: mov edx,len ;string length BxU1Q&
mov ecx,msg ;string start K=)R!e8
mov ebx,1 ;file handle: stdout DeSTo9A}!
mov eax,4 ;sys_write 4Ccb!?
int 80h ;kernel system call A'8K^,<