~nch/onward

c4f900dbe7afc632f6e9f716efd5dc12013898ea — nc 4 years ago c3bd095
added some more basic instructions
2 files changed, 26 insertions(+), 13 deletions(-)

M makefile
M onward.s
M makefile => makefile +1 -1
@@ 1,2 1,2 @@
onward: onward.s
	fasm onward.s && ld -o onward onward.o
	fasm onward.s && ld -nostdlib -o onward onward.o

M onward.s => onward.s +25 -12
@@ 46,6 46,10 @@ macro next {
    jmp qword rax
}

IMMEDIATE = 0
COMPILE = 1
var_STATE: db IMMEDIATE

section '.text' ; readable executable

    defcode drop


@@ 65,6 69,20 @@ section '.text' ; readable executable
    pushd rax
    next

    defcode lit
    mov rax, [rsi]
    pushd rax
    lea rsi, [rsi + ADDR_SIZE]
    next

    defcode lbrac
    mov [var_STATE], byte IMMEDIATE
    next

    defcode rbrac
    mov [var_STATE], byte COMPILE
    next

    defcode emit
    mov r8, rsi ; backup rsi since we'll clobber it
    mov rax, SYS_WRITE


@@ 81,23 99,18 @@ section '.text' ; readable executable
    mov rdi, 0
    syscall

    defcode branch
    add esi, [esi]
    next

start:
    cld
    mov rsi, instrs
    pushd byte 'h'
    pushd byte 'e'
    pushd byte 'l'
    pushd byte 'l'
    pushd byte 'o'
    next

instrs:
    dq sdup
    dq emit
    dq emit
    dq emit
    dq emit
    dq emit
    dq lit, '*'
    dq emit
    dq branch, -32
    dq exit
;section '.rodata' ;readable