“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 eY\tO"Hc
PgB=<#9
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。
1ikkm7
;r49H<z
以下是用不同语言写成的Hello World程序的几个例子: d;D^<-[i
Ada q1r\60M
with Ada.Text_Io; use Ada.Text_Io; tK g%5;v
procedure Hello is xW/JItF
begin 5c{=/}Y
Put_Line ("Hello, world!"); ++R-_oQ
end Hello; E4}MvV=
4d!&.Qo9
A~*Wr+pv
汇编语言 sFSrMI#R
vIN6W
x86 CPU,DOS,TASM DQ9 <N~l
MODEL SMALL |g8
]WFc
IDEAL d>@{!c-
STACK 100H .a;-7|x
I #1_
DATASEG 0Yfk/}5
HW DB 'Hello, world!$' wLkHU"'
m$QFtrvy
CODESEG -W! g>^.
MOV AX, @data "
8;D^
MOV DS, AX r\_rnM)_xN
MOV DX, OFFSET HW p"q-sMYl
MOV AH, 09H LFen!FnM
INT 21H 8'^eH1d'
MOV AX, 4C00H ~+l%}4RZ
INT 21H _[0Ugfz(
END vFl|
_32ltnBX
!Z%QD\knY
x86 CPU,GNU/Linux,NASM A.35WGu&:
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). gxU(&
;Enter this into "hello.asm" then type: (>WV)
;"nasm -f elf hello.asm" *eUL1m8Y
;"ld hello.o -o hello" rp=?4^(u
;"./hello" %{zM> le9
eZ}FKg%2[
section .data ;data section declaration LwY_6[Ef
msg db 'Hello World!',0AH m6lNZb]
len equ $-msg ;string length *aG0p&n}
KgAc0pz{7H
section .text ;code section declaration [jAhw>
global _start ;entry point (start of execution) #Sn&Wo
_start: mov edx,len ;string length &hV;3";
mov ecx,msg ;string start <@JU0Z"a=
mov ebx,1 ;file handle: stdout
[POy"O
mov eax,4 ;sys_write P-+ ^YN,
int 80h ;kernel system call em>CSBx
b#82G`6r
mov ebx,0 ;return value ?W.Y
x7c
mov eax,1 ;sys_exit Z>CFH9
int 80h ;kernel system call qIb(uF@l"
Ir0er~f+z
dW:
x86 CPU,Windows,MASM32 NA0hQGN}
.386 ZQ~?
.model flat,stdcall ?I7H ):
option casemap:none JmY"Ja,&
;Include 文件定义 *}mtVa_|
include windows.inc W@UHqHr:\
include user32.inc oiFtPki
includelib user32.lib g2iSc
include kernel32.inc `-w;=_Bm
includelib kernel32.lib 0_&oMPY
;数据段 F." L{g
.data fF *a/\h %
szCaption db 'A MessageBox!',0 c)E'',-J_2
szText db 'Hello,world!',0 !r[uwJ=
;代码段 K0+J!-a]7
.code lzwr]J%|?
start: y<;#*wB
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK HX<5i>]0\u
invoke ExitProcess,NULL ;dPLi4=o
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> wz:w R+
end start WcqYpPv
u9GQ)`7Z@
A Ys<IMQ
AWK vWj|[| <rX
BEGIN { print "Hello, world!" }
;xry
(#
?~^ut
Ad`;O+/;
BASIC nE/T)[1|
传统版BASIC(例如GWBASIC): e|{6^g<ru
W=G[hT5L{
10 PRINT "Hello, world!" { >4exyu6
20 END &