Rewrite everything in rust
This commit is contained in:
parent
db5aeb333c
commit
ffad349a41
46 changed files with 1698 additions and 2410 deletions
|
@ -1,44 +0,0 @@
|
|||
PROGRAM_SIZE = (32 * 1024)
|
||||
INSTRUCTION_SIZE = 3
|
||||
|
||||
main_jump = (PROGRAM_SIZE - INSTRUCTION_SIZE - INSTRUCTION_SIZE)
|
||||
|
||||
.org 0x0000
|
||||
|
||||
push main_jump
|
||||
jmp
|
||||
|
||||
data:
|
||||
answer:
|
||||
ANSWER_SIZE = 52
|
||||
.bw "The answer to life, the universe, and everything is ", 0, ANSWER_SIZE
|
||||
|
||||
main:
|
||||
push answer
|
||||
loop:
|
||||
dup
|
||||
load
|
||||
emit
|
||||
|
||||
inc
|
||||
dup
|
||||
push (answer + ANSWER_SIZE)
|
||||
neq
|
||||
push loop
|
||||
jif
|
||||
drop
|
||||
|
||||
push 40
|
||||
push 2
|
||||
add
|
||||
print
|
||||
|
||||
push "!"
|
||||
emit
|
||||
push "\n"
|
||||
emit
|
||||
stp
|
||||
|
||||
.org main_jump
|
||||
push main
|
||||
jmp
|
|
@ -1,41 +0,0 @@
|
|||
; Constants
|
||||
PROGRAM_SIZE = (32 * 1024)
|
||||
INSTRUCTION_SIZE = 3
|
||||
|
||||
main_jump = (PROGRAM_SIZE - INSTRUCTION_SIZE - INSTRUCTION_SIZE)
|
||||
|
||||
; Base organisation / offset
|
||||
.org 0x0000
|
||||
|
||||
; Static data
|
||||
push main_jump
|
||||
jmp ; Skip data section as following data is not program code
|
||||
|
||||
data:
|
||||
; Message data
|
||||
msg:
|
||||
MSG_SIZE = 12 ; Define size of message
|
||||
.bw "Hello World!", 0, MSG_SIZE ; Embed byte words in binary
|
||||
|
||||
; Main label
|
||||
main:
|
||||
push msg
|
||||
loop:
|
||||
dup
|
||||
load
|
||||
emit
|
||||
|
||||
inc
|
||||
dup
|
||||
push (msg + MSG_SIZE)
|
||||
neq
|
||||
push loop
|
||||
jif
|
||||
push "\n"
|
||||
emit
|
||||
stp
|
||||
|
||||
; Jump to main label
|
||||
.org main_jump
|
||||
push main
|
||||
jmp
|
22
examples/test.asm
Normal file
22
examples/test.asm
Normal file
|
@ -0,0 +1,22 @@
|
|||
main:
|
||||
push 40
|
||||
push (42 - 40)
|
||||
|
||||
tss
|
||||
tlr 0x5
|
||||
pop
|
||||
tss
|
||||
tlr 0x6
|
||||
pop
|
||||
|
||||
alu 0x06
|
||||
tls
|
||||
|
||||
alu 0x12
|
||||
tlr 0x5
|
||||
tls
|
||||
|
||||
dbg
|
||||
|
||||
ts 0xffff
|
||||
tlr 0x0
|
6
examples/test.lisp
Normal file
6
examples/test.lisp
Normal file
|
@ -0,0 +1,6 @@
|
|||
(module test
|
||||
"Main module"
|
||||
(defun main ()
|
||||
"Program entrypoint"
|
||||
(let ((x (+ 40 2))))
|
||||
(debug x)))
|
Loading…
Add table
Add a link
Reference in a new issue