Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

DISREGARD JAVA, ACQUIRE ASSEMBLER

Name: Anonymous 2010-11-17 22:44

Living in the stone age was never so refreshing!


;; compile instructions:
;;
;;    nasm -f elf hello.asm -o hello.o
;;    ld hello.o -o hello
;;


;;; standard file descriptors for the sys_write macro
%define IO_STDOUT 1
%define IO_STDERR 2
%define IO_STDIN  3


;; calls the kernel (duh)
%macro callkernel 0
    int 0x80
%endmacro

;;; @syntax sys_write(int fd, char* data, int datalen)
%macro sys_write 3
    ; 4 is "write"
    mov    eax, 4
    ; file descriptor
    mov    ebx, %1
    ; pointer to the value being passed
    mov    ecx, %2
    ; length of output (in bytes)
    mov    edx, %3
    ; call the kernel
    callkernel
%endmacro


;;; @syntax sys_exit(int  status)
%macro sys_exit 1
    ;; status
    mov ebx, %1
    ;; system call number (sys_exit)
    mov eax, 1
    ;;call kernel
    callkernel
%endmacro


;;; @syntax printstr(int fd, char* data, ...)
%macro printstr 2+
    SECTION .data
        %%__printstr_fd_str  db %2, 0
        %%__printstr_fd_len  equ $- %%__printstr_fd_str
    SECTION .text
        sys_write %1, %%__printstr_fd_str, %%__printstr_fd_len
%endmacro


;; entry
SECTION .data
    msg db      "Hello World", 0xa
    len equ     $-msg

SECTION .text
    GLOBAL _start

    _start:
        sys_write IO_STDOUT, msg, len
        printstr 1, "poop", 0xa
        printstr 1, "++====================================++", 0xa
        printstr 1, "||                                    ||", 0xa
        printstr 1, "||        ____________________        ||", 0xa
        printstr 1, "||       /\                   \       ||", 0xa
        printstr 1, "||      /  \                   \      ||", 0xa
        printstr 1, "||     /    \   ALL DEAD HERE   \     ||", 0xa
        printstr 1, "||    /      \___________________\    ||", 0xa
        printstr 1, "||    |      |                  |     ||", 0xa
        printstr 1, "||    | ___  |   __     ___     |     ||", 0xa
        printstr 1, "||    | | |  |  |__|    |_|     |     ||", 0xa
        printstr 1, "||    | | |  |                  |     ||", 0xa
        printstr 1, "||    | | |  |                  |     ||", 0xa
        printstr 1, "||    ////////__________________|     ||", 0xa
        printstr 1, "||                                    ||", 0xa
        printstr 1, "++====================================++", 0xa
        sys_exit 42

Name: Anonymous 2010-11-18 12:37

>>11
I have more or less abandoned the project, but I'm planning a new version written in my own lisp-dialect. I was planning on writing an interpreter in Haskell for bootstrapping both a compiler and kernel in the dialect itself. The idea was to use it for some kind of strongly typed file system that doubles as a symbol table, doing access restrictions and running everything in ring 0 kind of like in Singularity.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List