hello world作为所有编程语言的起始阶段,占据着无法改变的地位,所有中/英/法/德/美……版本的编程教材中,hello world总是作为第一个TEST记录于书本之中,所有的编程第一步就在于此了!经典之中的经典!
hello world!
Hello, world程序是指在计算机屏幕上输出Hello, world这行字符串的计算机程序,“hello, world”的中文意思是“世界,你好”。这个例程在Brian Kernighan和Dennis M. Ritchie合著的The C Programming Language中被使用而广泛流行。因为它的简洁、实用,并包含了一个程序所应具有的一切,因此为后来的编程类图书的作者提供了范例,一直待续到今。
hello world程序全集
ActionScript
1 | trace(Hello, world!); |
Ada
1 2 3 4 5 6 | with TEXT_IO; procedure HELLO is begin TEXT_IO.PUT_LINE (Hello, world!); end HELLO; |
汇编语言
x86 CPU,GNU/Linux,NASM
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | section .data msg db 'Hello, world!',0xA len equ $-msg section .text global _start _start: mov edx,len mov ecx,msg mov ebx,1 mov eax,4 int 0x80 mov ebx,0 mov eax,1 int 0x80 |
x86 AT&T、Gas
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | .data msg : .string Hello, world!\n len = . - msg .text .global _start _start: movl $len, %edx movl $msg, %ecx movl $1 , %ebx movl $4 , %eax int $0x80 movl $0 , %ebx movl $1 , %eax int $0x80 |
x86 CPU、Windows、MASM32
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | .386 .model flat,stdcall option casemap:none ;========================================================== include windows.inc include user32.inc includelib user32.lib include kernel32.inc includelib kernel32.lib ;========================================================== .data szCaption db A MessageBox!, 0 szText db Hello, world!, 0 ;========================================================== .code start: invoke MessageBox, NULL, addr szText, addr szCaption, MB_OK invoke ExitProcess, NULL ;========================================================== end start |
8086操作系统
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | [BITS 16] org 0x7c00 mov ax,cs mov ds,ax mov es,ax call DispStr jmp $;End Hear DispStr: mov ax, BootMessage mov bp, ax mov cx, 16;How long is the String mov ax, 0x1301 mov bx, 0x000c mov dl, 0 int 0x10 ret BootMessage: db Hello, world! times 510-($-$$) db 0x0 dw 0xaa55; Bootable Mark |