Hello World! on modern processors.

From: Eric J. Korpela <korpela_at_ssl.berkeley.edu>
Date: Tue Aug 21 19:51:15 2001

Of course you should be able to go even smaller on a linux system by going to
assembly and using the interrupt version of syscall().

.text
.globl _start
_start:
        xor %eax,%eax
        movb $4,%al
        xor %ebx,%ebx
        movb $1,%bl
        movl $message,%ecx
        xor %edx,%edx
        movb $14,%dl
        int $0x80
        xor %eax,%eax
        movb $1,%al
        xor %ebx,%ebx
        movb $0,%bl
        int $0x80
message:
        .string "Hello, world!\n"


as -o hello.o hello.s
ld -Bstatic -o hello hello.o
strip hello

It's still annoying that 36 bytes of code and data end up in a 404 byte
file. I suppose that's the price of a code loader that supports dynamic
linking. Even if no files are linked, you need to tell it that no files
are linked.

It's not like it really matters. The 6502 version on the Apple would still
have taken a full disk block.

Eric
Received on Tue Aug 21 2001 - 19:51:15 BST

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:33:34 BST