“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 EK4%4<"
>h8m)Q
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 c~tl0XU1
ZRf9 'UwS
以下是用不同语言写成的Hello World程序的几个例子: u~OlJ1V
Ada T!,5dt8L
with Ada.Text_Io; use Ada.Text_Io; Bg),Q8\I
procedure Hello is |aLK_]!
begin ow \EL
Put_Line ("Hello, world!"); e$s&B!qJ
end Hello; XnP?hw%
^"7-`<J
8p 4[:M@
汇编语言 1*p6UR&
=
zmxki
x86 CPU,DOS,TASM he~8V.$
MODEL SMALL $\ZWQct
IDEAL fJ8>nOh
STACK 100H 4tkT\.
\C$e+qb~{
DATASEG ^>an4UJt
HW DB 'Hello, world!$' B]tj0FB`-*
RVAku
CODESEG Xb:*
KeZq
MOV AX, @data kKlNhP(
MOV DS, AX -ZE YzZqY
MOV DX, OFFSET HW qfXt%6L
MOV AH, 09H {{G3^ysa
INT 21H l1T`[2
MOV AX, 4C00H Z$J-4KN
INT 21H 4}DFCF%B
END _OG9wi(Fpx
)K?7(H/j
KWo Ps%G
x86 CPU,GNU/Linux,NASM R{c~jjd
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). =l:V9u-I^
;Enter this into "hello.asm" then type: !@lx|=#
;"nasm -f elf hello.asm" a!bW^?PcK
;"ld hello.o -o hello" U Y*`R
;"./hello" BR|0uJ.M
].rKfv:
section .data ;data section declaration j-BNHX
msg db 'Hello World!',0AH JL
G!;sov
len equ $-msg ;string length ifS#9N|8
%JDQ[%3qY
section .text ;code section declaration =)Hu(;Yv
global _start ;entry point (start of execution) nam]eW
_start: mov edx,len ;string length Jw5@#j
mov ecx,msg ;string start WD\Yx~o
mov ebx,1 ;file handle: stdout >N al\
mov eax,4 ;sys_write _yAY5TIv
int 80h ;kernel system call T/ ECW
MUbKlX
mov ebx,0 ;return value zlP{1z;nV
mov eax,1 ;sys_exit <O=0 ^V
int 80h ;kernel system call l|
uiC%T
0&