“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 &GlwC%$S
wS4.8iJ
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 @c<3b2
LUuZ9$t0J"
以下是用不同语言写成的Hello World程序的几个例子: 6xWe=QGE
Ada hJDi7P
with Ada.Text_Io; use Ada.Text_Io; VCn{mp*h
procedure Hello is LM}Ib.
begin `|,`QqDQ
Put_Line ("Hello, world!"); HR
;)|j{!
end Hello; aCQ?fq
T(e!_VY|m
3T"j)R_=l
汇编语言 2C/$Ei^t
/h*>P:i].
x86 CPU,DOS,TASM c:-!'l$ !
MODEL SMALL Z2TL #@
IDEAL h<Ft_#|o[
STACK 100H HvM)e.!
%7"X(Ts7B
DATASEG cJ1#ge%4
HW DB 'Hello, world!$' "kMguK}c
wm)#[x #
CODESEG |
\'rP_I>
MOV AX, @data W6"v)Jc>_
MOV DS, AX 3
|hHR
MOV DX, OFFSET HW VwOW=4`6
MOV AH, 09H Svc|0Ad&
INT 21H t: #6sF
MOV AX, 4C00H Ttxqf:OMf
INT 21H <FWF<r3F
END 7RUofcax
dgA-MQ5{
JcbwDlUb
x86 CPU,GNU/Linux,NASM (xVsDAp=@
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). |P -8HlOr
;Enter this into "hello.asm" then type: E_8\f_%wK
;"nasm -f elf hello.asm" 6`v7c!7
;"ld hello.o -o hello" \RvvHty-V
;"./hello" o(:[r@Z0z
/C>wd
section .data ;data section declaration Q\cjPc0y
msg db 'Hello World!',0AH SzUpWy&
len equ $-msg ;string length 4$*%gL;f^
/%&2HDA)
section .text ;code section declaration %n
hm
global _start ;entry point (start of execution) c0hwc1kv-
_start: mov edx,len ;string length n@U n
mov ecx,msg ;string start f}1&HI8r
mov ebx,1 ;file handle: stdout :{IO=^D=$
mov eax,4 ;sys_write l-ct?T_@
int 80h ;kernel system call &_"]5/"(
]`&Yqg
mov ebx,0 ;return value WDg+J
mov eax,1 ;sys_exit [P 06lIO
int 80h ;kernel system call }; f#^gz'
2I&o69x?
L
]w/P|
x86 CPU,Windows,MASM32 GDD '[;
.386 .h9l7
nZt
.model flat,stdcall Gi "941zVl
option casemap:none <