“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 ,b%T[s7
.^6"nnfA#
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 2;VggPpT
Z?kLAhy!
以下是用不同语言写成的Hello World程序的几个例子: C:
@T5m
Ada t9685s
with Ada.Text_Io; use Ada.Text_Io; tIR"y:U+
procedure Hello is ( 6|S42
begin ],YIEOx6
Put_Line ("Hello, world!"); -K9bC3H
end Hello; P,^`|\#7
E"ijN s
na,j
汇编语言 2>Bx/QF@<
K4b#
y~@
x86 CPU,DOS,TASM Dm?>U1{
MODEL SMALL y w)q3zC
IDEAL &=oW=g 2
STACK 100H a;jXMR
/B73|KB+
DATASEG _h",,"p#o
HW DB 'Hello, world!$' g}
7FR({b
yJkERiJV
CODESEG RsIR}.*
MOV AX, @data B#9rqC
MOV DS, AX Z[[o u?c
MOV DX, OFFSET HW -]\cUQ0
MOV AH, 09H (\}>+qS[
INT 21H x2(!r3a
MOV AX, 4C00H .>NhC"
INT 21H >DeG//rv
END P$?3\`U;
!r]elX
}>Gnpc
x86 CPU,GNU/Linux,NASM eY^;L_7}p
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). MQ>.^]B]o
;Enter this into "hello.asm" then type: {_ti*#
;"nasm -f elf hello.asm" %T4htZa
;"ld hello.o -o hello" b1Bu5%bt,:
;"./hello" KLK
'_)|CT
i>#[*.|P
section .data ;data section declaration qfE>N?/
msg db 'Hello World!',0AH ]@)T]
len equ $-msg ;string length /*\pm!]._^
, v,mBYaU
section .text ;code section declaration )y&}c7xW
global _start ;entry point (start of execution) &"]Uh
_start: mov edx,len ;string length ZWH?=Bk:
mov ecx,msg ;string start ICwhqH&
mov ebx,1 ;file handle: stdout 1sKKmtgH
mov eax,4 ;sys_write HL-zuZa`Ju
int 80h ;kernel system call 9N5ptdP.d
\lwYDPY:
mov ebx,0 ;return value __<