“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 )%(H'omvl
[S T7CrwC
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 nA XWbavY
'xc=N
以下是用不同语言写成的Hello World程序的几个例子: I-|1eR+3
Ada Vb8{OD3PK
with Ada.Text_Io; use Ada.Text_Io; r1Cq8vD*m
procedure Hello is ?N!.:~~k
begin %KmhR2v
Put_Line ("Hello, world!"); Pt%EyFG
end Hello; 5B+I\f&
uze5u\
1ba* U~OEg
汇编语言 ?O#,|\v?]
V']1j
x86 CPU,DOS,TASM u-#J!Z<T8
MODEL SMALL l(
0:CM
IDEAL ^>!~%Vv7!
STACK 100H yM*<BV
*v9 {f?
DATASEG {'eF;!!Dy
HW DB 'Hello, world!$' O2>W#7
5NAB^&{Z<X
CODESEG sBm/9vu
MOV AX, @data t_ZWd#x+;
MOV DS, AX (
G# W6
MOV DX, OFFSET HW \{M/Do:
MOV AH, 09H &IgH]?t
INT 21H gpzZs<ST
MOV AX, 4C00H 9jTm g%
INT 21H ?;)F_aHp
END lC(g&(\{
kv'gs+,e
/ :@X<
x86 CPU,GNU/Linux,NASM F
{T\UX
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). Pi:=0,"XOp
;Enter this into "hello.asm" then type: {oc7Chv=/H
;"nasm -f elf hello.asm" /QCyA%y
;"ld hello.o -o hello" 04cNi~@m
;"./hello" 0] $5jW6]
\mp5G&+/Q
section .data ;data section declaration _Zs]za.#)|
msg db 'Hello World!',0AH ck4g=QpD{
len equ $-msg ;string length GLIP;)h1
G`r*)pdm
section .text ;code section declaration h9 &V
global _start ;entry point (start of execution) jW!)5(B[A
_start: mov edx,len ;string length K+s
xO/}h
mov ecx,msg ;string start oc3}L^aD
mov ebx,1 ;file handle: stdout d8Kxtg
Y
mov eax,4 ;sys_write
@s@67\
int 80h ;kernel system call <E.$4/T
:Y ;\1J<b1
mov ebx,0 ;return value vs~lyM/
mov eax,1 ;sys_exit }8cX0mZ1j
int 80h ;kernel system call p~w|St7jg
rCa2$#Z
-P3;7_}]:h
x86 CPU,Windows,MASM32 Rr>h8Ni <
.386 hu+% X.F4
.model flat,stdcall !HP/`R
option casemap:none kwd)5J
;Include 文件定义 !1\jD
include windows.inc !p~K;p,
include user32.inc HGjGV]N5
includelib user32.lib T>;Kq;(9
include kernel32.inc xz$S5tgDQK
includelib kernel32.lib Ut
xe
;数据段 "gPAxt
.data h8MkfHH7{
szCaption db 'A MessageBox!',0 #)xg$9LQb
szText db 'Hello,world!',0 ].eY]o}=
;代码段 *t+E8)qL
.code SLze) ?.
start: =_L
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK @GiR~bKZ
invoke ExitProcess,NULL U0M>A
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> T?Dq2UW
end start ohA@Zm8O
\#A=twp
Dy[
YL
AWK |e@Bi#M[
BEGIN { print "Hello, world!" } '0xJp|[xVP
Y%V|M0 0`
KrFV4J[
BASIC plY`lqm
传统版BASIC(例如GWBASIC): drQioH-
",ic"
~
10 PRINT "Hello, world!" Nv
iPrp>c
20 END ZREAEGi{
~"*;lT5KX
或在提示符输入: X&<