“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 j7QX,_Q
W6c]-pc
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 +K",^6%1
/+K?
以下是用不同语言写成的Hello World程序的几个例子: WN]<q`.
Ada 'I}:!Z
with Ada.Text_Io; use Ada.Text_Io; J4$!
68
procedure Hello is .^(/n9|o-
begin YPDf
Y<?v
Put_Line ("Hello, world!"); v6(E3)J7
end Hello; 256LH Y|6
~l[ra
uq3{hB#
汇编语言 F"+o@9]
iI1n2>V3y
x86 CPU,DOS,TASM /u<nLj 1
MODEL SMALL {}~: &.D
IDEAL Kb;dKQ
STACK 100H /7c~nBU
RBKOM$7
DATASEG :*514N
HW DB 'Hello, world!$' xb2?lL]
El_Qk[X|A
CODESEG [IZM.r`Z
MOV AX, @data uYI@9U
MOV DS, AX y^>Q/H\
MOV DX, OFFSET HW fT\:V5-
MOV AH, 09H 4<,|*hAT
INT 21H ;F:fM!l=
MOV AX, 4C00H zt24qTKL
INT 21H ;i uQ?MR3
END Xf'=+f2p
`(y(w-:W1
C]u',9,
x86 CPU,GNU/Linux,NASM 9' 1B/{
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). E\7m<'R
;Enter this into "hello.asm" then type: Rg&-0b
;"nasm -f elf hello.asm" )}v3q6?_
;"ld hello.o -o hello" R9vT[{!i
;"./hello" )EM7,xMz
+!t}
section .data ;data section declaration }CL"S_>1
msg db 'Hello World!',0AH ^?"\?M1
len equ $-msg ;string length bp<^R
l(W[_ D
section .text ;code section declaration 4Aes#{R3v
global _start ;entry point (start of execution) E8\XNG)V4
_start: mov edx,len ;string length -[7O7'
mov ecx,msg ;string start #U7_a{cn"M
mov ebx,1 ;file handle: stdout )>\}~s
mov eax,4 ;sys_write ,*id'=S
int 80h ;kernel system call F'PQqb {
Lz9#A.
mov ebx,0 ;return value g:ErZ;[
mov eax,1 ;sys_exit 6SM:x]`##,
int 80h ;kernel system call AbwbAm+
;#+0L$<t
G#`\(NW
x86 CPU,Windows,MASM32 _cH@I?B
.386
'1SG(0
.model flat,stdcall }l0&a!C
option casemap:none >cMd\%^t
;Include 文件定义 P\m7 -
include windows.inc LHCsk{3
include user32.inc w?vVVA
includelib user32.lib .Ce8L&