“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 ^~kFC/tQ
58gt*yVu
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 vH\nL>r
O7_NXfh|
以下是用不同语言写成的Hello World程序的几个例子: K]azUK7
Ada ^J=txsx
with Ada.Text_Io; use Ada.Text_Io; sAAIyPJts
procedure Hello is 1~iBzPU2
begin /SM#hwFxJ&
Put_Line ("Hello, world!"); "lj:bxM2C
end Hello; AE@Rn(1.
T=KrT7
NZ? =pfK\s
汇编语言 E]Gq!fA&<
;0}"2aGY
x86 CPU,DOS,TASM XXdMp poR
MODEL SMALL 9*Mg<P"
IDEAL :95_W/l
STACK 100H -8J@r2 \
JG+o~tQC
DATASEG gYIYA"xN`
HW DB 'Hello, world!$' oM7-1O
,T>2zSk
CODESEG (HgdmN%
MOV AX, @data sU3V)7"
MOV DS, AX Yy:sZJ
MOV DX, OFFSET HW [~H`9Ab=
MOV AH, 09H k5\
zGsol
INT 21H )$.9WlQ
MOV AX, 4C00H B'~i Z65
INT 21H H_$f
v_
END 7.'j~hJL
x~,?Zj)n?C
*m Tc4&*
x86 CPU,GNU/Linux,NASM R}mWHB_h"
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). .TU15AAc
;Enter this into "hello.asm" then type: @?NLME
;"nasm -f elf hello.asm" !LSWg:Ev+
;"ld hello.o -o hello" IZ ha* 7
;"./hello" T{2//$T?
jtC ob'n8
section .data ;data section declaration <^$b1<@
msg db 'Hello World!',0AH GdwHm
len equ $-msg ;string length =7Gi4X%
fH{$LjH(
section .text ;code section declaration xg!\C@$
global _start ;entry point (start of execution) VH*(>^OfF
_start: mov edx,len ;string length 5 `mVe0uI
mov ecx,msg ;string start ag4^y&
mov ebx,1 ;file handle: stdout 6m<9^NT
mov eax,4 ;sys_write zT 40,rk
int 80h ;kernel system call q:eAL'OkM
JugQ +0
mov ebx,0 ;return value F#9KMu<<cI
mov eax,1 ;sys_exit l@9:VhU(
int 80h ;kernel system call _E-GHj>k
z
wY)GX
nr6[rq
x86 CPU,Windows,MASM32 -2XIF}.Hu
.386 +n]Knfi
.model flat,stdcall u9%:2$[
option casemap:none E 4(muhY
;Include 文件定义 {_D'\i(Y_
include windows.inc BbhdGFG1
include user32.inc 5{=MUU=
includelib user32.lib gU$3Y#R
include kernel32.inc Z.19v>-c
includelib kernel32.lib :njUaMFoMA
;数据段 %[;KO&Ga