“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 U.g7' `Z<
us%dw&
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 "ld4v+o8l
9ozN$:
以下是用不同语言写成的Hello World程序的几个例子: F6^Xi"R[
Ada _=!Rl#
with Ada.Text_Io; use Ada.Text_Io; ]06orBV
procedure Hello is 2NMS'"8
begin &m<:&h& b
Put_Line ("Hello, world!"); 2%o@ ?Rp
end Hello; b/"&E'5-`\
"V|&s/9
StZ GKY[Q
汇编语言 mu`:@7+Yp
P`^3-X/
x86 CPU,DOS,TASM T)4pLN
E
MODEL SMALL CNP!v\D
IDEAL [[
{L#
STACK 100H t,H=;U#
O\0]o!
DATASEG &q8oalh
HW DB 'Hello, world!$' mcO/V-\5'
drRi<7
i
CODESEG W@S>#3,
MOV AX, @data nD#QC=}
MOV DS, AX W5a7HkM
MOV DX, OFFSET HW V&e9?5@
MOV AH, 09H &}}UdJ`
INT 21H "L ,)4v/J
MOV AX, 4C00H % \N52
INT 21H \;#T.@c5
END iwM$U(
9
b&]_5 GGc
r2!\Ts 5v
x86 CPU,GNU/Linux,NASM )c432).Z
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). 9W5~I9%
;Enter this into "hello.asm" then type: uUmkk
;"nasm -f elf hello.asm" L F<{/c9,
;"ld hello.o -o hello" vT1StOx<V
;"./hello" iG+hj:5
=*2_B~`
section .data ;data section declaration *z852@
msg db 'Hello World!',0AH
^W8kt
len equ $-msg ;string length zH)M,+P
vU(uu:U9
section .text ;code section declaration nev@ykP6
global _start ;entry point (start of execution) o,(]w kF
_start: mov edx,len ;string length cl,\N\
mov ecx,msg ;string start =o_Ua^mr
mov ebx,1 ;file handle: stdout ;YGCsLT<xt
mov eax,4 ;sys_write R V@'$`Q
int 80h ;kernel system call ;-]' OiS;
)SjhOvm
mov ebx,0 ;return value - 2DvKW$
mov eax,1 ;sys_exit 9Su4nt`i
int 80h ;kernel system call cpLlkR O
u([|^~H]
tRC*@>I$
x86 CPU,Windows,MASM32 *h([ai"1-
.386 9Ub##5$[,
.model flat,stdcall |J:|56kVZq
option casemap:none &AUtUp
kOo
;Include 文件定义 M0) q
include windows.inc &d,!^9
include user32.inc h;C/} s
includelib user32.lib *Rx&