Files
damn_simple_architecture/resources/dsa/main.dsa
T
2026-02-13 21:42:59 +00:00

141 lines
2.4 KiB
Plaintext

// GENERATED BY DSC COMPILER
// Generated at 2026-02-10 19:36:18
// Imports
include alloc: "./lib/memory/block_alloc.dsa"
include print: "./lib/io/print.dsa"
//
// Globals & Reserved Memory
//
// Entry Point
dw stack: 0x010000
db message: "Process Exited with code:"
_init:
ldw stack, bpr 0
mov bpr, spr
push zero
call main
call print::print_newline
lwi message, rg0
push rg0
call print::print
pop zero
call print::print_hex_word
pop zero
hlt
// Return
_ret:
mov bpr, spr
pop bpr
return
db str_5: "successful free of ptr"
// fn main() -> u32
main:
push bpr
mov spr, bpr
lli 32, rg0
lli 64, rg1
// push arg 1
push rg0
// push arg 0
push rg1
call alloc::init
pop rg2
pop zero
push rg2
// push arg 0
push rg2
call print::print_hex_word
pop zero
call print::print_newline
ldw spr, rg0 0
stw rg0, spr 0
// push arg 0
push rg0
call alloc::alloc
pop rg1
push rg1
// push arg 0
push rg1
call print::print_hex_word
pop zero
lli 200, rg0
ldw spr, rg1 0
stw rg0, rg1 0
stw rg1, spr 0
call print::print_newline
ldw spr, rg0 4
stw rg0, spr 4
// push arg 0
push rg0
call alloc::alloc
pop rg2
push rg2
// push arg 0
push rg2
call print::print_hex_word
pop zero
call print::print_newline
ldw spr, rg0 4
ldw rg0, rg2 0
stw rg0, spr 4
// push arg 0
push rg2
call print::print_num
pop zero
ldw spr, rg2 4
stw rg2, spr 4
addi spr, 4, rg3
ldw spr, rg2 8
stw rg2, spr 8
// push arg 1
push rg3
// push arg 0
push rg2
call alloc::free
pop zero
pop zero
ldw spr, rg2 8
stw rg2, spr 8
// push arg 0
push rg2
call alloc::alloc
pop rg3
push rg3
call print::print_newline
ldw spr, rg2 0
stw rg2, spr 0
// push arg 0
push rg2
call print::print_hex_word
pop zero
call print::print_newline
ldw spr, rg2 8
stw rg2, spr 8
// push arg 0
push rg2
call print::print_hex_word
pop zero
ldw spr, rg2 8
lli 0, rg4
cmp rg2, rg4
lli 1, rg5
jeq _cmp_end_1
lli 0, rg5
_cmp_end_1:
cmp rg5, zero
jeq _else_3
_then_2:
lwi str_5, rg4
stw rg2, spr 8
// push arg 0
push rg4
call print::print
pop zero
jmp _end_4
_else_3:
nop
_end_4:
lli 0, rg4
stw rg4, bpr 8
jmp _ret