“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 JsHxQ0Tw
-d\AiT
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 RcKQER
m&(%&}g
以下是用不同语言写成的Hello World程序的几个例子: f/$-Nl.
Ada 3W%f#d$`
with Ada.Text_Io; use Ada.Text_Io; 00$ @0
procedure Hello is vCYSm 0
begin \pT^Zhp)
Put_Line ("Hello, world!"); nEeQL~:
end Hello; Vq? 8u/
H'j_<R N
401/33yBJ
汇编语言 60.[t9pk6
d;*OO xQV
x86 CPU,DOS,TASM jb#1&L14
MODEL SMALL 5#N"WHz!
IDEAL v ^ FV
t
STACK 100H O?+tY
y?
~4p]E'b
DATASEG VNJDl
HW DB 'Hello, world!$' P':]A{<Z
^59YfC<f
CODESEG [esX{6,i
MOV AX, @data uyS^W'fF
MOV DS, AX {7j6$.7J$&
MOV DX, OFFSET HW ZEXj|wC
MOV AH, 09H ]x5(bnWx
INT 21H Lqz}&A
MOV AX, 4C00H >b/k|?xP
INT 21H `2Z4#$.
END uM}dZp 1
J, (U<%n
u(TgWp5WF
x86 CPU,GNU/Linux,NASM QI
:/,w
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). mfp`Iy"}+
;Enter this into "hello.asm" then type: &+|jJ{93z
;"nasm -f elf hello.asm" 75^)Ni
;"ld hello.o -o hello" UeK,q>i
;"./hello" 5Tcl<Y6l
Dn{19V.L
section .data ;data section declaration ouu-wQ|(mM
msg db 'Hello World!',0AH :_I
wc=
len equ $-msg ;string length g9grfN
"'&>g4F`o
section .text ;code section declaration )\:lYI}Wpm
global _start ;entry point (start of execution) *cI6&;y
_start: mov edx,len ;string length f0HV*%8
mov ecx,msg ;string start D!OG307P
mov ebx,1 ;file handle: stdout +lk\oj$S+
mov eax,4 ;sys_write inq4CGY
int 80h ;kernel system call 4P-'(4I)
+0JH"L5!
mov ebx,0 ;return value =%#$HQ=
mov eax,1 ;sys_exit /4f 5s#hR
int 80h ;kernel system call A{u\8-u
D
KMbs
,~ia$vI}R
x86 CPU,Windows,MASM32 ><:lUt*N2
.386 y<Z#my$`|n
.model flat,stdcall (d GM;Dq8
option casemap:none OJC*|kN-#^
;Include 文件定义 ??esB&