“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 tW3Nry
zids2/_*
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 nqib`U@"
~_4$|WKl
以下是用不同语言写成的Hello World程序的几个例子: `g(r.`t^
Ada MrS~u
with Ada.Text_Io; use Ada.Text_Io; l;;"v) C8
procedure Hello is r@H7J 5<Y-
begin cbX<
Put_Line ("Hello, world!"); KMV&c
end Hello; vnv:YQV/ir
2&:w_KJ
_^] :tL6
汇编语言 +H3;{ h9,
!O/(._YB`
x86 CPU,DOS,TASM %4h$/~
MODEL SMALL f\vg<lca
IDEAL 3*<~;Z' z4
STACK 100H ,N2|P:x
>iWw
i'T=
DATASEG d@<~u,Mt&F
HW DB 'Hello, world!$' CDRz3Hu U
h%%dRi
CODESEG ^36m$J $
MOV AX, @data IdL~0;W7
MOV DS, AX 1n+JHXR\
MOV DX, OFFSET HW VrZ6m
MOV AH, 09H ?C|b>wM/
INT 21H )Hlc\Mgy
MOV AX, 4C00H gn4Sz")
INT 21H N51RBA
END 3*[YM7y
K<D=QweOon
EN@Pr `R
x86 CPU,GNU/Linux,NASM :|E-Dx4F6H
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). P}$DCD<$U
;Enter this into "hello.asm" then type: ZklZU,\!|v
;"nasm -f elf hello.asm" %0^taA
;"ld hello.o -o hello" FTZaN1%`
;"./hello" oxgh;v*
c *]6>50
section .data ;data section declaration sT% ^W
msg db 'Hello World!',0AH oi/bp#(fa
len equ $-msg ;string length ^-pHhh|g
"_36WX
section .text ;code section declaration Uz;
pNWMk
global _start ;entry point (start of execution) Bis'59?U_
_start: mov edx,len ;string length `]l*H3+hg
mov ecx,msg ;string start R"k}wRnxY
mov ebx,1 ;file handle: stdout SRpPLY{:F
mov eax,4 ;sys_write 6 2#dSd}HG
int 80h ;kernel system call Z3Y(g
V|zatMHs
mov ebx,0 ;return value I'T@}{h
mov eax,1 ;sys_exit uMM?s?q
int 80h ;kernel system call "A%JT3
r4FGz!U
Umt?COc
x86 CPU,Windows,MASM32 4?cIn4}
.386 b'5L|1d
.model flat,stdcall q8e34Ly7
option casemap:none CLX!qw]@ +
;Include 文件定义 T@, tlIM
include windows.inc IA?v[xu
include user32.inc 6.
6g9
includelib user32.lib p:8&&v~I
include kernel32.inc Y1h)0_0
includelib kernel32.lib p$OkWSi~
;数据段 f<aJiVP
.data I~P]_DmM
szCaption db 'A MessageBox!',0 BjyGk+A
szText db 'Hello,world!',0 j@+QwZL|
;代码段 ;Jq 7E
.code c2fbqM~
start: 1 n<7YO7}
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK 8<