“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 1F=x~FMvY
9SrV,~zD
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 ev; &$Hc
O&)Y3 O1
以下是用不同语言写成的Hello World程序的几个例子: 33; ytd
Ada Nb$ )YMbA
with Ada.Text_Io; use Ada.Text_Io; `1P
&
procedure Hello is WN0^hDc-
begin 0ul2rZc
Put_Line ("Hello, world!"); Pvtf_Qo^
end Hello; '
ft
|
X9P-fF?0
PBUc9/
汇编语言 )a.U|[:y[+
.8,lhcpY
x86 CPU,DOS,TASM !,\]> c
MODEL SMALL N=wB1gJ
IDEAL 5%Q!R%
STACK 100H qn<~
LxQ
/5o~$S
DATASEG /q> "">
HW DB 'Hello, world!$' @M(vaJB8u
,
w_ Ew
CODESEG shi#K<gVC
MOV AX, @data ?e BN_a,r6
MOV DS, AX 55#H A?cR
MOV DX, OFFSET HW $`uL^ hlj]
MOV AH, 09H Kp"o0fh<9
INT 21H \Wo,^qR
MOV AX, 4C00H hWUZn``U$|
INT 21H #bGt%*Re p
END SDot0`s>
U zc`,iV$
WB= gN:?
x86 CPU,GNU/Linux,NASM NZ
Xmrc{S
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). b&!X#3(KT
;Enter this into "hello.asm" then type: Ly^r8I
;"nasm -f elf hello.asm" 0iwx$u7[
;"ld hello.o -o hello" iR_X,&p
;"./hello" !7_Q_h',
5T,`j=\
section .data ;data section declaration #vIF]Y
msg db 'Hello World!',0AH IQR?n}ce
len equ $-msg ;string length wc ^z9y
S3 &L
section .text ;code section declaration TEY%OIzU+
global _start ;entry point (start of execution) M*t{?o/t;
_start: mov edx,len ;string length RhYf+?2
mov ecx,msg ;string start nlJxF5/
mov ebx,1 ;file handle: stdout Fd3V5h
mov eax,4 ;sys_write N5g!,3
int 80h ;kernel system call 0{ \AP<
ba
,2.|
mov ebx,0 ;return value @o_-UsUX
mov eax,1 ;sys_exit R7vO,kZ6Q
int 80h ;kernel system call )4DF9 JpD
xvb5-tK
-
oas}8A)
x86 CPU,Windows,MASM32 f 1]1ZOb
.386 c$>Tfa'H
.model flat,stdcall O[$&]>x]]
option casemap:none 8E|S`I
;Include 文件定义 `|Ih"EZ
include windows.inc wVp
include user32.inc v\&Wb_;A
includelib user32.lib }"A.[9 b
include kernel32.inc |E|d"_Ma
includelib kernel32.lib $yG=exh3v
;数据段 y_QK _R<