“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 c=a;<,Rzb
bP|-GCKM8
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 X'%BS
hY *^rY'
以下是用不同语言写成的Hello World程序的几个例子: Nr"GxezU+A
Ada 0C"2?etMx
with Ada.Text_Io; use Ada.Text_Io; 7|[Dr@.S
procedure Hello is . S;o#Zw*R
begin t: ,lz8Y~
Put_Line ("Hello, world!"); ADP3Nic
end Hello; <]#_&Na
W'E3_dj+
VG$%Vs
汇编语言 Tc/<b2\g
ycEp,V;[Z
x86 CPU,DOS,TASM :9q|<[Y^
MODEL SMALL LW/> %
IDEAL '~z`kah
STACK 100H 1-<?EOYaE
5-'Z.[ImB?
DATASEG jH;L7
HW DB 'Hello, world!$' 8u"C7} N_
x
#|t#N%
CODESEG 5g'aNkF6>
MOV AX, @data (tT%rj!
MOV DS, AX j~cG#t]
MOV DX, OFFSET HW gF;C% }
MOV AH, 09H @ kba^z
INT 21H Q'j00/K
MOV AX, 4C00H &`-e; Xt
INT 21H yV6U<AP$3
END <K/iX%b?
>Il{{{\>
:g-vy9vb
x86 CPU,GNU/Linux,NASM nn">
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). `Cy;/95m
;Enter this into "hello.asm" then type: -
s{&_]A~
;"nasm -f elf hello.asm" |y?W#xb
;"ld hello.o -o hello" hsQ*ozv[)
;"./hello" l~@ -oE
MQy,[y7I
section .data ;data section declaration EIg:@o&Jj
msg db 'Hello World!',0AH ?8<R)hJa<
len equ $-msg ;string length B7%m7GM
THy
section .text ;code section declaration ,W_".aguX
global _start ;entry point (start of execution) g`"_+x'
_start: mov edx,len ;string length M{Vi4ehOq
mov ecx,msg ;string start 3XUsw1,[
mov ebx,1 ;file handle: stdout C
[8='i26
mov eax,4 ;sys_write N]|)O]/[
int 80h ;kernel system call lZ`@ }^&
7L]Y.7>
mov ebx,0 ;return value ^5FwYXAxi
mov eax,1 ;sys_exit wqX!7rD/g)
int 80h ;kernel system call Ro2!$[P
=trLL+vGw'
k4"O}jQO
x86 CPU,Windows,MASM32 _gCi@uXS3
.386 Rp}Sm,w(
.model flat,stdcall Q[aBxy
(
option casemap:none
H^$7=
;Include 文件定义 COH>B1W@
include windows.inc &