“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 "S@%d(lg
U_c.Z{lC4
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 6rOd80\
sjV>&eb
以下是用不同语言写成的Hello World程序的几个例子: !j?2HlIK+
Ada _/5mgn<GK
with Ada.Text_Io; use Ada.Text_Io; 8wqHr@}p
procedure Hello is sP5\R#
begin QGnBNsA h
Put_Line ("Hello, world!"); q.>{d%?
end Hello; pTlNJ!U>
Ey!+rq}
k:0HsN!F9
汇编语言 \{[Gdj`
`8%2F}x}qD
x86 CPU,DOS,TASM ;u0MY
MODEL SMALL $k|k 5cP8x
IDEAL }l>0m
STACK 100H &8 ~+^P1w
hqVFb.6[
DATASEG H`;q@
HW DB 'Hello, world!$' Fh4kd>1D
a$SGFA}V
CODESEG 14p <0BG
MOV AX, @data fWywegh
MOV DS, AX 0x\bDWZ_
MOV DX, OFFSET HW gUB%6v G\I
MOV AH, 09H -&*
4~
INT 21H SablF2doa
MOV AX, 4C00H BV X6
INT 21H &i,xod6$
END gzthM8A
?HBNd&gZ1G
0;j)rmt
x86 CPU,GNU/Linux,NASM ~P85Or
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). s1xl*lKX%
;Enter this into "hello.asm" then type: ch}t++`l]
;"nasm -f elf hello.asm" Kuz
/
;"ld hello.o -o hello" :!\?yj{{
;"./hello" B#_<?
ljTnxg/?
W
section .data ;data section declaration _Jc[`2Uv_c
msg db 'Hello World!',0AH Re{vO&.
len equ $-msg ;string length +KV`+zic+
J?~El&
section .text ;code section declaration i5sNCt
global _start ;entry point (start of execution) l* =\0
_start: mov edx,len ;string length i[_WO2
mov ecx,msg ;string start C$~2FTx
mov ebx,1 ;file handle: stdout >'^Tp7\
mov eax,4 ;sys_write Uv~r]P)
int 80h ;kernel system call Y9)uy 8c
%OeA"#
mov ebx,0 ;return value <0r2m4z
mov eax,1 ;sys_exit w NlC2is
int 80h ;kernel system call mjDaus59
|?=K'[5
lr:rQw9
x86 CPU,Windows,MASM32 0Z{f!MOh
.386 RjY(MSc
.model flat,stdcall .mzy?!w0q
option casemap:none P5Y:c@u2
;Include 文件定义 gwj+~vSfi
include windows.inc >TT4;p h
include user32.inc xt7ZrT
includelib user32.lib /G`'9cD
include kernel32.inc 3,2|8Q,((!
includelib kernel32.lib E({W`b~_f
;数据段 9K`(Ys&
.data 60B6~@]P
szCaption db 'A MessageBox!',0 I'Dc9&2
szText db 'Hello,world!',0 fD<9k
;代码段 Fy^=LrH=D
.code LE!xj 0
start: 2 5DXJb^:
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK ;by`[)
invoke ExitProcess,NULL gJE m
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> J3OxM--8"
end start 1&JPyW
eM";P/XaX
B8){
AWK }&+b\RE
BEGIN { print "Hello, world!" } uOzol~TU)
tA2Py
fk5xIW
BASIC OT[&a6