“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 1cOR?=G~
m)p|NdTZc8
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 7@<.~*Bl6
EO)JMV?6
以下是用不同语言写成的Hello World程序的几个例子: (1D1;J4g
Ada A)]&L`s
with Ada.Text_Io; use Ada.Text_Io; zb9G&'7
procedure Hello is lg-_[!4Z
begin '9f0UtT|[
Put_Line ("Hello, world!"); >va_,Y}
end Hello; =fRS UtX
1}wDc$O
9lYfII}4(
汇编语言 0"OEOYs}
d9S/_iCI
x86 CPU,DOS,TASM ny13+Q`^
MODEL SMALL g8MW6Y
IDEAL u:p OP
STACK 100H )]C]K B
rk1,LsZVS
DATASEG #E!^oZm<Z
HW DB 'Hello, world!$' #b[bgxm
GO"|^W
CODESEG bfz7t!A)A
MOV AX, @data ~
q-Z-MA
MOV DS, AX uG7]s]Wdz;
MOV DX, OFFSET HW $f3 IO#N
MOV AH, 09H <)T| HKx
INT 21H ?3BcjD0
MOV AX, 4C00H LhLAQ2~
INT 21H ; H ;h[
END /lC# !$9vz
_rYW|*cIF
h-ii-c?R@0
x86 CPU,GNU/Linux,NASM r!Dk_|Cd
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). 8C3oi&av/{
;Enter this into "hello.asm" then type: -yqgs>R(d
;"nasm -f elf hello.asm" A3/[9}(U
;"ld hello.o -o hello" \bd KLcKI,
;"./hello" *`+zf7-f
zG_n x3
section .data ;data section declaration cQt&%SVT]E
msg db 'Hello World!',0AH ~NK $rHwi%
len equ $-msg ;string length ,A` |jF
EF
:g0$
section .text ;code section declaration !j'LZ7
global _start ;entry point (start of execution) 9Q,>I6`l
_start: mov edx,len ;string length }
KyoMs
mov ecx,msg ;string start ?]D&D:Z?I
mov ebx,1 ;file handle: stdout z9S
(<