“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 KVZB`c$<t
}UyQGRZ=
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 xvl$,\iqE
v ,")XPY
以下是用不同语言写成的Hello World程序的几个例子: 8maWF.xq
Ada 'jt7H{M
with Ada.Text_Io; use Ada.Text_Io; '5h`="
procedure Hello is TpU\IQ
begin tF;0P\i
Put_Line ("Hello, world!"); =Jm[1Mgt
end Hello; Lx,=Up.
>)M{^
Z],j|rWy6
汇编语言 xXJ*xYn"}
xsa`R^5/c
x86 CPU,DOS,TASM *PF<J/Pr
MODEL SMALL .n<vhLDQn
IDEAL $zP5Hzx
STACK 100H )Do 0
U[wx){[|
DATASEG bq/Aopfr
HW DB 'Hello, world!$' 9c^ ,v_W@
~0MpB~ {xd
CODESEG =E9\fRGU
MOV AX, @data j_JY[sex
MOV DS, AX Tpl]\L1v-
MOV DX, OFFSET HW
0pE>O7
MOV AH, 09H D:T]$<=9
INT 21H @&\Y:aRO%i
MOV AX, 4C00H K<P d.:
INT 21H QFP9"FM5F
END f|{iW E2d
868X/lL
8'PZA,CW
x86 CPU,GNU/Linux,NASM fo ~uI(rk
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). wm~7`&
;Enter this into "hello.asm" then type: 3U<m\A1
;"nasm -f elf hello.asm" ceUe*}\cr
;"ld hello.o -o hello" B=0^Rysg
;"./hello" 9q"kM
4l 67B]o
section .data ;data section declaration x9YQd69
msg db 'Hello World!',0AH $toTMah
w
len equ $-msg ;string length E+]}KX:
zud_BOq{f
section .text ;code section declaration Im;%.J
global _start ;entry point (start of execution) X%yG{\6:
_start: mov edx,len ;string length :[CV_ME.;
mov ecx,msg ;string start }$_@yt<{W@
mov ebx,1 ;file handle: stdout o]1BWwtY&
mov eax,4 ;sys_write a7g;8t-&
int 80h ;kernel system call $INB_/RE
wQSan&81Q
mov ebx,0 ;return value <- \|>r Q
mov eax,1 ;sys_exit ;wwc;wQ'
int 80h ;kernel system call ?X@!jB,Pv
G80N8Lm
GRcPzneiz
x86 CPU,Windows,MASM32 x7S\-<8
.386 !Gmnck&+
.model flat,stdcall @j|E"VYY
option casemap:none &5 "!0
;Include 文件定义 3^/w`(-{@
include windows.inc >V6t
L;+
include user32.inc =UKxf
includelib user32.lib _[HZ[ 9c!
include kernel32.inc L-|l$Ti"
includelib kernel32.lib G^.N$wcv
;数据段 IR-n:z
.data b1C)@gl !Z
szCaption db 'A MessageBox!',0 [lzd'
szText db 'Hello,world!',0 ,iV%{*p]
;代码段 t]HY@@0g
.code w9'>&W8T
start: Mq\=pxC@
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK hhU_kI
invoke ExitProcess,NULL D7hTn@I
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> syw1Z*WK
end start b6-N2F1Fs
L;3%8F\-.
n{gEIUo#
AWK q%sZV>
BEGIN { print "Hello, world!" } -`faXFW'
9L>?N:%5
mi=mwN%UB
BASIC _wKwiJs
传统版BASIC(例如GWBASIC): 7( 84j5zb
h ;*x1BVE
10 PRINT "Hello, world!" YYQvt
20 END @;egnXxF<