“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 spdvZU=}
N"" BCh"
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 d/ARm-D
eZSNNgD<:
以下是用不同语言写成的Hello World程序的几个例子: =osv3>&q
Ada &7`^i.fh)
with Ada.Text_Io; use Ada.Text_Io; YpH&<$x:
procedure Hello is S'4(0j
begin A Y*e@nk\
Put_Line ("Hello, world!"); UaWl6 Y&Vu
end Hello; XiL~TCkx4
|2RC# ]/-Y
,eTUhK
汇编语言 ;%<,IdhN
6kNrYom
x86 CPU,DOS,TASM !9[>L@#G
MODEL SMALL UmKI1l
IDEAL iH/6M
STACK 100H d{SG
Cr 9d
Jth[DUH8H
DATASEG n@C[@?D
HW DB 'Hello, world!$' eO?p*"p" F
U^Q:Y}^
CODESEG fz\9 S
MOV AX, @data !ePr5On
MOV DS, AX XZsz/#
MOV DX, OFFSET HW mVVD!
MOV AH, 09H S 5/R_5
INT 21H D)j(,vt
MOV AX, 4C00H J T-J#Ag
INT 21H ;\]b T;#
END zG ^$"f2
?AJKBW^
7*
yzEM
x86 CPU,GNU/Linux,NASM *~t6(v?
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). 4)@mSSfn.
;Enter this into "hello.asm" then type: WU
quN
;"nasm -f elf hello.asm" X$ s:>[H
;"ld hello.o -o hello" t=Xv;=daB
;"./hello" umiBj)r
E%rk[wI
section .data ;data section declaration ;$smH=I
msg db 'Hello World!',0AH d8[J@M53|T
len equ $-msg ;string length q1QL@Ax
\P.I)n`8 y
section .text ;code section declaration X~lVVBO
global _start ;entry point (start of execution) :-/M?,Q"
_start: mov edx,len ;string length t.7?
mov ecx,msg ;string start BI3@|,._N
mov ebx,1 ;file handle: stdout 2w["aVr
=
mov eax,4 ;sys_write ,1 [q^-9
int 80h ;kernel system call }T&iewk
NYrQ$N"
mov ebx,0 ;return value v6>_ j
L
mov eax,1 ;sys_exit {ys=Ndo8
int 80h ;kernel system call {u#;?u=|
9y<*8bI
9~p[
x86 CPU,Windows,MASM32 c(!6^qk]!`
.386 ]ooIrY8
.model flat,stdcall !HnXXVW
option casemap:none nQ5n-A&["
;Include 文件定义 _F$aUtb%O
include windows.inc VU&7P/\f%
include user32.inc .P[ _<8
includelib user32.lib %= fHu+
include kernel32.inc yXHUJgjl/
includelib kernel32.lib KY51rw.
;数据段 [n \2
.data ]Q>.HH
szCaption db 'A MessageBox!',0 uI1q>[
szText db 'Hello,world!',0 XCU7xi$d
;代码段 w8U&ls