“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 2A
{k>TjQ
:!J!l u
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 `[/BG)4
bZ:w_z[3=
以下是用不同语言写成的Hello World程序的几个例子: ZN',=&;n'
Ada 5H`k$[3V
with Ada.Text_Io; use Ada.Text_Io; ?ZE1>L7e
procedure Hello is 8x[q[
begin $UgM7V$
Put_Line ("Hello, world!"); zd"o #(sv
end Hello; ~{oM&I|d8
-0Y8/6](
"VB-=. A
汇编语言 ]hN%~
~$>
A1>R8Zuhy
x86 CPU,DOS,TASM {}{|trr-E
MODEL SMALL oF)+f4
IDEAL / IAK'/
STACK 100H { ~FYiX
GS4!c8>
DATASEG \KDOI 7
HW DB 'Hello, world!$' Z#nj[r!l}
bsR&%C
CODESEG kT!FC0E{
MOV AX, @data a/{T;=_GY
MOV DS, AX jo0p/5;
MOV DX, OFFSET HW "PLZZL$+
MOV AH, 09H qGr(MDLc
INT 21H KKl8tI\u~
MOV AX, 4C00H 0:Ak4L6k
INT 21H fLxFF
END 7-Fh!=\f/
Z,_yE*q
N:Q}Lil
x86 CPU,GNU/Linux,NASM 00n6v;X
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). bxK1v7
;Enter this into "hello.asm" then type: `4gm'C
;"nasm -f elf hello.asm" }`\+_@w
;"ld hello.o -o hello" gNo.&G [
;"./hello" ~;3N'o
LezM=om.
section .data ;data section declaration BoHMz/DB
msg db 'Hello World!',0AH aKhI|%5kA
len equ $-msg ;string length b_z;^y~
y`! 3Z} 7
section .text ;code section declaration f'TdYG
global _start ;entry point (start of execution) =uIu0_v
_start: mov edx,len ;string length 9^c\$"2B
mov ecx,msg ;string start 39BGwKXb
mov ebx,1 ;file handle: stdout khyn4
mov eax,4 ;sys_write w<tr<Pu'
int 80h ;kernel system call -{-w5_B$
`$fwLC3j
mov ebx,0 ;return value <