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-17 22:51

Disregard enterprise, acquire satori.

Name: Anonymous 2010-11-17 22:58

pig disgusting macro'd ASM

Name: Anonymous 2010-11-17 23:02

>>3
eat shit and die faggot

Name: Anonymous 2010-11-17 23:03

Typically ASM confuses me, but the way you did it makes it look so easy. Is that windows or linux onry tho?

Name: Anonymous 2010-11-17 23:15

>>5
Linux only. And thank you. :3

Name: Anonymous 2010-11-17 23:16

>>5
His code is obviously written for Linux, but Windows also has excellent macro assemblers, and the Linux ones ALSO work on Windows (they have ports).

Name: Anonymous 2010-11-18 1:33

Name: Anonymous 2010-11-18 6:21


format PE GUI
entry main

section '.text' code import readable writeable executable
    dd 0,0,0,RVA kernel_name,RVA kernel_tab
    dd 0,0,0,RVA user_name,RVA user_tab
    dd 0,0,0,0,0
   
    kernel_tab:
        ExitProcess dd RVA _ExitProcess
        dd 0
    user_tab:
        MessageBoxA dd RVA _MessageBoxA
        dd 0
   
    kernel_name db 'kernel32.dll',0
    user_name db 'user32.dll',0
   
    _ExitProcess:
        dw 0
        db 'ExitProcess',0
   
    _MessageBoxA:
        dw 0
        db 'MessageBoxA',0
       
    cap db 'Sup?',0
    msg db 'Hello',0
       
    main:
        push 0
        push cap
        push msg
        push 0
        call [MessageBoxA]
       
        push 0
        call [ExitProcess]

Name: Anonymous 2010-11-18 6:53

wgat

Name: Anonymous 2010-11-18 8:10

>>8
sup akh, how's YHBT coming along? Any progress or HIBT?

Name: Anonymous 2010-11-18 10:58

It's all nice and good until you have to print something interpreted as an int to screen.

Name: Anonymous 2010-11-18 11:57

>>12
I think you'll find that's quite trivial, even in base 10.

Name: Anonymous 2010-11-18 12:34

I am pussy. Can I learn bytecode instead?

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.

Name: Anonymous 2010-11-18 14:43

>>15
lolol is ur dof ded

Name: Anonymous 2010-11-18 23:24

>>8
buffa: times 256 db 0
BUFFA

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