aboutsummaryrefslogtreecommitdiffstats
path: root/asm
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2023-04-13 14:48:34 +0300
committerJan Tuomi <jans.tuomi@gmail.com>2023-04-13 14:49:59 +0300
commit9d4c6fc299294ac36f7082599edce19286fa0f99 (patch)
treee7601bb1cd9950482f125377d25b6d5d40b72e62 /asm
parentafd5f32e56d3d30bfa98fb35deff51febf50e594 (diff)
Add @let directive, start pondering interrupt control
Diffstat (limited to 'asm')
-rw-r--r--asm/bootstrap.atk1623
-rw-r--r--asm/ext_std.py4
-rw-r--r--asm/fibo.atk1614
-rw-r--r--asm/ram_offset.atk162
4 files changed, 31 insertions, 12 deletions
diff --git a/asm/bootstrap.atk16 b/asm/bootstrap.atk16
new file mode 100644
index 0000000..c7ab63e
--- /dev/null
+++ b/asm/bootstrap.atk16
@@ -0,0 +1,23 @@
+@let stack_segment 0x8000
+@let vector_table 0x10
+
+@address vector_table
+ hlt_isr ; 0x10 ISR0
+ hlt_isr ; 0x11 ISR1
+ hlt_isr ; 0x12 ISR2
+ hlt_isr ; 0x13 ISR3
+ stack_segment ; 0x14 Stack address
+
+@label hlt_isr
+ ldi 0x55 RA
+ hlt
+@label program_segment
+
+@address 0x0
+; set up stack pointer to point to beginning of stack segment
+ ldi 0x14 RA
+ ldr RA RF
+ jpi main
+
+@address program_segment
+; set up address for program code
diff --git a/asm/ext_std.py b/asm/ext_std.py
index 11da8aa..de7cd43 100644
--- a/asm/ext_std.py
+++ b/asm/ext_std.py
@@ -48,6 +48,9 @@ def expand_dec(reg: str) -> ExpandResult:
def expand_mov(from_reg: str, to_reg: str) -> ExpandResult:
return [["ali", "al_plus", from_reg, "0", to_reg]]
+def expand_nop() -> ExpandResult:
+ return [["ali", "al_plus", "RA", "0", "RA"]]
+
def expand_spu(reg: str) -> ExpandResult:
return [["str", reg, "__STACK_POINTER"]] + expand_inc("__STACK_POINTER")
@@ -89,6 +92,7 @@ expansions: OpExpansionDict = {
"inc": expand_inc,
"dec": expand_dec,
"mov": expand_mov,
+ "nop": expand_nop,
"spu": expand_spu,
"spo": expand_spo,
"csr": expand_csr,
diff --git a/asm/fibo.atk16 b/asm/fibo.atk16
index cae5f5d..fb375b3 100644
--- a/asm/fibo.atk16
+++ b/asm/fibo.atk16
@@ -2,17 +2,11 @@
@opt csr_scratch RH
@use ext_std:*
-; jump over data segment
- jpi program
-
-; data segment
-@include ram_offset
-
-@label program
-; set up stack pointer to point to beginning of RAM
- ldi ram_offset_addr RA
- ldr RA RF
+; bootstrap code (must be called to setup mandatory data)
+; will jump to label main
+@include bootstrap
+@label main
; call fibo subroutine with parameter 10
ldi 10 RA
csi fibo
diff --git a/asm/ram_offset.atk16 b/asm/ram_offset.atk16
deleted file mode 100644
index e8c9255..0000000
--- a/asm/ram_offset.atk16
+++ /dev/null
@@ -1,2 +0,0 @@
-@label ram_offset_addr
- 0x8000