“Hello, World!”程序是一个只在计算机屏幕上打印出“Hello, World!”(英语,意为“世界,你好!”)字串的计算机程序。该程序通常是计算机程序设计语言的初学者所要学习编写的第一个程序。它还可以用来确定该语言的编译器、程序开发环境以及运行环境已经正确安装。 )W c#?K
@B1rtw6
将Hello World程序作为第一个学写的程序,现在已经成为一种传统。该程序最早出现在由Brian Kernighan和Dennis Ritchie写的计算机程序设计教程《C语言程序设计》。 H9 't;Do
bu$5gGWVf
以下是用不同语言写成的Hello World程序的几个例子: qA03EU
Ada &[kwM395
with Ada.Text_Io; use Ada.Text_Io; qkR.{?x
procedure Hello is +\}]`uS:
begin fEgZ/p!g
Put_Line ("Hello, world!"); .j;My%)?p
end Hello; us5`?XeX]
O'!k$iJNb
CBO8^M<K
汇编语言 #"f:m`
Fmsg*s7w
x86 CPU,DOS,TASM a_pkUOu6
MODEL SMALL s+0$_&xR
IDEAL 6?hv,^
STACK 100H
Q.cxen
ZPMX19
DATASEG (zTr/
HW DB 'Hello, world!$' u}u2{pO!
3K54:
CODESEG 9{>m04888
MOV AX, @data Nf$Y-v?i
MOV DS, AX Q<78<#I
MOV DX, OFFSET HW -EITz
MOV AH, 09H L5eaQu
INT 21H *D|6g|Hb
MOV AX, 4C00H h`5au<h<
INT 21H P;A"`Il
END ~ae68&L6
W'6*$Ron
&<v#^2S3
x86 CPU,GNU/Linux,NASM Z\@vN[[
;"Hello World" for Linux on Intel 80x86 using nasm (Intel syntax). xat)9Yb}0
;Enter this into "hello.asm" then type: 3xj<ATSe
;"nasm -f elf hello.asm" 9K)OQDv%6D
;"ld hello.o -o hello" .Yh-m
;"./hello" <H#D/?n5
eo,m ^&
section .data ;data section declaration JfC.U,7Nc
msg db 'Hello World!',0AH M,mj{OY~x
len equ $-msg ;string length "-I>
ImvkB~8N
section .text ;code section declaration 5+ VdZ'@
global _start ;entry point (start of execution) ;ATk?O4T
_start: mov edx,len ;string length i?mDR$X:
mov ecx,msg ;string start 6 !+"7r6
mov ebx,1 ;file handle: stdout ZtB0:'o;
mov eax,4 ;sys_write ]C]tLJ!M
int 80h ;kernel system call OlV>zam
N%>/
e'(
mov ebx,0 ;return value :*4yR46
mov eax,1 ;sys_exit <