“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 Z/ L%?zH
o'8%5M@
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 $9u:Ox
2
vI:_bkii
以下是用不同语言写成的Hello World程序的几个例子: ;j+*}|!
Ada qx*N-,M%k(
with Ada.Text_Io; use Ada.Text_Io; .:e#!~Ki
procedure Hello is ;Eh"]V,e
begin _,igN>
Put_Line ("Hello, world!"); X1BqN+=@9
end Hello; mP?}h
f*T}Ov4
,fo7.
h4{
汇编语言 ?[%.4i;-h
MM( ,D&
Z
x86 CPU,DOS,TASM RJ{J~-q{
MODEL SMALL fA=Lb^,M
IDEAL BgY|v
[M&
STACK 100H 0wAB;|~*62
^s$U
n6v[
DATASEG :^FH.6}x
HW DB 'Hello, world!$' ^==Tv+T9U
Ds{bYK_y
CODESEG T7l,}G
MOV AX, @data f 0~Z@\
MOV DS, AX R[TaP7n
MOV DX, OFFSET HW Mgu9m8
`J
MOV AH, 09H $-<yX<.
INT 21H /AYq^
MOV AX, 4C00H k?/! `
INT 21H #Yy5@A}`o
END ~{N#JOY}Z
uzLm TmM+
jaMpi^C
x86 CPU,GNU/Linux,NASM S&;)F|-q
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). -^8OjGat
;Enter this into "hello.asm" then type: gV*4{d`
;"nasm -f elf hello.asm" OC\cN%qlw
;"ld hello.o -o hello" _^!C4?2!
;"./hello" [$fB]7A
!"aGo1$$
section .data ;data section declaration >xH?`I7;f
msg db 'Hello World!',0AH ]{I>HA5[
len equ $-msg ;string length )0Vj\>
{7v|\6@e3
section .text ;code section declaration M3dUGM
global _start ;entry point (start of execution) TP Y&O{q
_start: mov edx,len ;string length u!fZ>kS
mov ecx,msg ;string start )ub!tm
mov ebx,1 ;file handle: stdout [~;wCW,1
mov eax,4 ;sys_write pTJ_DH
int 80h ;kernel system call L$ jii
r\y\]AmF
mov ebx,0 ;return value x/0x&la
mov eax,1 ;sys_exit V=+p8nE0
int 80h ;kernel system call h,]lN'JG{
'z+Pa^)v
g1B P
x86 CPU,Windows,MASM32 O_5;?$[m
.386 NVDIuh
.model flat,stdcall m5hu;>gt
option casemap:none /N@NT/.M<
;Include 文件定义 QEmktc1 7
include windows.inc <