“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 !@( M_Z'
9KXym }
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 Bk+{}
P2>:p%Z
以下是用不同语言写成的Hello World程序的几个例子: zgK;4
22$m
Ada Pfm*<,'x"[
with Ada.Text_Io; use Ada.Text_Io; )eECOfmnZ
procedure Hello is >Z}@7$(7!~
begin B-$+UE>%
Put_Line ("Hello, world!"); XHy?
end Hello; }bp.OV-+
3a%xn4P
`%uK0qw"
汇编语言 S:#e8H_7m]
(JWv *p
x86 CPU,DOS,TASM Q2q|*EL
MODEL SMALL Eevw*;$x
IDEAL N50fL
STACK 100H E$w#+.QP
6Hda]y
DATASEG #aa1<-&H
HW DB 'Hello, world!$' rxs8De
A$Wx#r7)
CODESEG 0EyAMu
MOV AX, @data 691G15
MOV DS, AX =9(tsB gTX
MOV DX, OFFSET HW X\kjAMuW/*
MOV AH, 09H N^lAG"Jao[
INT 21H wajZqC2yg
MOV AX, 4C00H 4x(F&0
INT 21H p/N 62G
END +SyUWoM
b]w[*<f?
0:. 6rp
x86 CPU,GNU/Linux,NASM /V#7=,,
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). #J\s%60pt
;Enter this into "hello.asm" then type: r4EoJyt
;"nasm -f elf hello.asm" ~zMDY F"&
;"ld hello.o -o hello" n%*tMr9 s
;"./hello" Z&A0hI4d
TQ?#PRB
section .data ;data section declaration X>}@EHT
msg db 'Hello World!',0AH :Z[(A"dA
len equ $-msg ;string length ~U9q-/(J/
kB
V/rw
section .text ;code section declaration >{b3>s~T
global _start ;entry point (start of execution) };^}2Xo+
_start: mov edx,len ;string length ]'tJ
S]
mov ecx,msg ;string start g**5z'7
mov ebx,1 ;file handle: stdout ^Wm*-4
mov eax,4 ;sys_write N2T&,&,t
int 80h ;kernel system call JxHv<p[
).Q[!lly
mov ebx,0 ;return value '=p?
mov eax,1 ;sys_exit [T-*/}4$
int 80h ;kernel system call ?]5Ix1
^(DL+r,
J
B(<.E2
x86 CPU,Windows,MASM32 5~Q Tg
.386 $7Cgo &J
.model flat,stdcall
{U^j&E
option casemap:none y`6\L$c
;Include 文件定义 Gp8psH
include windows.inc fQO
""qh
include user32.inc e:BDQU
includelib user32.lib c`ftd>]
include kernel32.inc Sj@15 W
includelib kernel32.lib **n y!
;数据段 )%t7\1)B3
.data :WO{x g
szCaption db 'A MessageBox!',0 &1l~&,,
szText db 'Hello,world!',0 *t]v}ZV*
;代码段 0X#+#[W
.code !UVk9
start: [EruyWK
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK bLco:-G1E1
invoke ExitProcess,NULL G%$}WA]|
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Td&