“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 TE3A(N'
8|OsVIe%
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 6ix8P;;}#
S{zi8Oc6
以下是用不同语言写成的Hello World程序的几个例子: aI{Ehbf=
Ada oM M`7wJw
with Ada.Text_Io; use Ada.Text_Io; HSE9-c=
procedure Hello is g
VplBF7{
begin /Z94<}C6b
Put_Line ("Hello, world!");
bF0y`
end Hello; 4%0eX]
#ih(I7prH
T'"aStt6
汇编语言 Np$pz
d@<(Z7|
x86 CPU,DOS,TASM 3Gubq4r
MODEL SMALL b*\K I
IDEAL q]ER_]%Gna
STACK 100H 2Xys;Dwx
k^:)|Z
DATASEG ^y]CHr
HW DB 'Hello, world!$' o['HiX
aqSHo2]DX9
CODESEG ^OnU;8IC
MOV AX, @data \!Cix}}1
MOV DS, AX Gt3V}"B3\
MOV DX, OFFSET HW DpI)qg#>V
MOV AH, 09H n*D-01vYP
INT 21H XXBN
Nr_CK
MOV AX, 4C00H ^$}9
Enj+Y
INT 21H 6sJN@dFA
END :
9wW*Ix
oi^2Pvauh
33z)F
x86 CPU,GNU/Linux,NASM ^1sX22k
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). lTBPq?4{
;Enter this into "hello.asm" then type: r({!ejT{U
;"nasm -f elf hello.asm" sKVN*8ia
;"ld hello.o -o hello" $!)Sgb
;"./hello" O0`sg90,C
rlEEf/m:
section .data ;data section declaration o{f|==<t3#
msg db 'Hello World!',0AH ;}"_hLX
len equ $-msg ;string length q|;_G#4
61L
vT"
section .text ;code section declaration MF)Xc\}0p
global _start ;entry point (start of execution) UE3(L
^
_start: mov edx,len ;string length # -e
mov ecx,msg ;string start WvQK$}Ax4N
mov ebx,1 ;file handle: stdout * $~H=4t
mov eax,4 ;sys_write N}HQvlLkF9
int 80h ;kernel system call $w4%JBZr
Cp` [0v~0
mov ebx,0 ;return value Vf9PHHH|
mov eax,1 ;sys_exit %5Hsd
int 80h ;kernel system call \
'G%%%;4
N3nFE:`u]
mrX 2w
x86 CPU,Windows,MASM32 Cgq/#2BM
.386 C8 9c2
.model flat,stdcall 1BO$xq
option casemap:none =
_X#JP79
;Include 文件定义 Q\|72NWS
include windows.inc 2#:/C:
include user32.inc (C>FM8$J
includelib user32.lib 4=!SG4~o
include kernel32.inc yr?*{;
includelib kernel32.lib a+sHW<QeS
;数据段
AV{3f`
.data 7N9~nEU
szCaption db 'A MessageBox!',0 #-*7<wN
szText db 'Hello,world!',0 sLrSi
;代码段 Z
M_
6A1
.code ywWF+kR_
start: qKNX^n;
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK Y7(E<1Yx
invoke ExitProcess,NULL ChO?Lm$y
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> uTTM%-DMHT
end start })RT2zw}
1henQiIO
>oSNKE
AWK R1OC7q
BEGIN { print "Hello, world!" } v'gP,UO-%D
)[_A{#&