“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 IR%a+;Xs
Rhx7eU#&
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 BQBO]<99
<E
BgHD)
以下是用不同语言写成的Hello World程序的几个例子: Prhq ~oI4
Ada 4T9hT~cT7
with Ada.Text_Io; use Ada.Text_Io; %~ecrQ;
procedure Hello is 4W.;p"S2
begin %`}CbD6
Put_Line ("Hello, world!"); RQU5T 2,
end Hello; Z=!*7@QY
?/)5U}*M0T
S/d})8~.
汇编语言 4_N)1u !
i&>,aiH@
x86 CPU,DOS,TASM gH\r# wy|
MODEL SMALL 0 \LkJ*i
IDEAL dtM@iDljj
STACK 100H #G.3a]p}"
MQY1he2M
DATASEG %T6#c7U_
HW DB 'Hello, world!$' ,mYoxEB kl
!Y]}&pUP
CODESEG +ZE&]BO{
MOV AX, @data <\^X,,WtO
MOV DS, AX @?Y^=0
MOV DX, OFFSET HW YC=BP5^
MOV AH, 09H R/^JyL
INT 21H cT0utR&
MOV AX, 4C00H 0uU%jN$
INT 21H 4&ea*w
END k #*|-?
&OhKx
o@LjSQ5!
x86 CPU,GNU/Linux,NASM qqzQKN
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). : 6>H\
;Enter this into "hello.asm" then type: HB`pK'gz
;"nasm -f elf hello.asm" 4rM77Uw>
;"ld hello.o -o hello" I9F[b#'Pn
;"./hello" DJQ]NY|
;@d%<yMf@
section .data ;data section declaration XFu@XUk!K
msg db 'Hello World!',0AH 4E
|6l
len equ $-msg ;string length ;7`<.y
g=Qga09
section .text ;code section declaration -Ez|
global _start ;entry point (start of execution) f6L_uk`{
_start: mov edx,len ;string length zW0AB8l
mov ecx,msg ;string start )i_FU~ LRq
mov ebx,1 ;file handle: stdout INbjk;k
mov eax,4 ;sys_write J82{PfQ"
int 80h ;kernel system call ~2H7_+.#
Jl]]nOBQ/
mov ebx,0 ;return value xD\Km>|i
mov eax,1 ;sys_exit Q"hI !PO+
int 80h ;kernel system call [V)sCAW
5GJ0E Z'X
;2@sn+@
x86 CPU,Windows,MASM32 "]_|c\98
.386 -/gS s<"
.model flat,stdcall |O4A+S
option casemap:none .@6]_h;
;Include 文件定义 +cV!=gDT
include windows.inc uPF yRWK
include user32.inc %UQ?k:aWp|
includelib user32.lib ~o/^=:*
include kernel32.inc 4[J3HLQ
includelib kernel32.lib ,#wVqBEk
;数据段 7lVIN&.=
.data #Y5I_:k
szCaption db 'A MessageBox!',0 F7;xf{n<
szText db 'Hello,world!',0 {-Y_8@&