“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 @=K> uyB
O2:m)@
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 I=D`:u\H
>
9JzYI^
以下是用不同语言写成的Hello World程序的几个例子: _Eq:Qbw#
Ada \$VtwVQ,b
with Ada.Text_Io; use Ada.Text_Io; |C=^:@}ri?
procedure Hello is hK@1
s
begin bRLmJt98P
Put_Line ("Hello, world!"); lR{eO~'~V
end Hello; #|A
@
Y%^&aac Z
=5oFutg`
汇编语言 }dAb}0XK.
1#(,Bq4
x86 CPU,DOS,TASM 2OAh7 '8<
MODEL SMALL "%A/bv\u
IDEAL [LL"86D
STACK 100H zO9$fU
M_T$\z;,
DATASEG "2'nLQ""q
HW DB 'Hello, world!$' [uc;M6o}?
j
&,vju
CODESEG 5;>M&qmN
MOV AX, @data Z&s+*&TM
MOV DS, AX [9z<*@$-
MOV DX, OFFSET HW
_"%d9B
MOV AH, 09H ^KF
INT 21H Gw~^6( Qu
MOV AX, 4C00H J^
P/2a#a
INT 21H +;Q&
END 17$JBQ,[
+_Fsiu_b
=XQ3sk6U
x86 CPU,GNU/Linux,NASM n6O1\}YB
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). !g=,O6
;Enter this into "hello.asm" then type: UmiW_JB
;"nasm -f elf hello.asm" ^^jF*)DT@
;"ld hello.o -o hello" @2CYv>
;"./hello" G/Kz_Y,
| (v/>t
section .data ;data section declaration MZn7gT0
msg db 'Hello World!',0AH ?lR)Hi
len equ $-msg ;string length +SrE
1^}()H62}
section .text ;code section declaration }C2I9Cl
global _start ;entry point (start of execution) EK@yzJ%
_start: mov edx,len ;string length KP_=#KD
mov ecx,msg ;string start H#m)`=nZSZ
mov ebx,1 ;file handle: stdout x2Y1B
mov eax,4 ;sys_write Q7"KgqpQ3
int 80h ;kernel system call ~bigaY
udp&