aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--atk16_asm/asm_pass0.py9
-rw-r--r--atk16_asm/builtin_asm/bootstrap.atk16 (renamed from resources/asm/bootstrap.atk16)0
-rw-r--r--resources/asm/fibo.atk166
-rw-r--r--resources/asm/idle_loop.atk168
-rw-r--r--resources/asm/tpu.atk162
-rw-r--r--test/e2e/bootstrap.atk1678
-rw-r--r--test/e2e/call_stack/run_fact.atk164
-rw-r--r--test/e2e/call_stack/run_mul.atk164
-rw-r--r--test/e2e/emulation_speed/long_loop.atk164
-rw-r--r--test/e2e/fibo/fibo.atk164
10 files changed, 15 insertions, 104 deletions
diff --git a/atk16_asm/asm_pass0.py b/atk16_asm/asm_pass0.py
index f6586cd..b30ddc0 100644
--- a/atk16_asm/asm_pass0.py
+++ b/atk16_asm/asm_pass0.py
@@ -29,7 +29,14 @@ def pass_0(lines: list[str], file_name: str) -> Result0:
match keyword:
case "@include":
asm_file_name = args[0] if args[0].endswith(".atk16") else args[0] + ".atk16"
- path = os.path.join(os.path.dirname(file_name), asm_file_name)
+ # if starts with %, use the path relative to this source file, not the current working directory
+ if asm_file_name.startswith("%"):
+ path = os.path.join(os.path.dirname(__file__), "builtin_asm", asm_file_name[1:])
+ # if absolute, use the absolute path
+ elif os.path.isabs(asm_file_name):
+ path = asm_file_name
+ else:
+ path = os.path.join(os.path.dirname(file_name), asm_file_name)
with open(path, "r") as f:
incl_lines = f.readlines()
diff --git a/resources/asm/bootstrap.atk16 b/atk16_asm/builtin_asm/bootstrap.atk16
index 9b024e6..9b024e6 100644
--- a/resources/asm/bootstrap.atk16
+++ b/atk16_asm/builtin_asm/bootstrap.atk16
diff --git a/resources/asm/fibo.atk16 b/resources/asm/fibo.atk16
index 34999a9..b2c20bd 100644
--- a/resources/asm/fibo.atk16
+++ b/resources/asm/fibo.atk16
@@ -1,10 +1,6 @@
-@opt stack_pointer RG
-@opt csr_scratch RH
-@use ext_std:*
-
; bootstrap code (must be called to setup mandatory data)
; will jump to label main
-@include bootstrap
+@include %bootstrap
@label main
; call fibo subroutine with parameter 10
diff --git a/resources/asm/idle_loop.atk16 b/resources/asm/idle_loop.atk16
index dd7d879..d821245 100644
--- a/resources/asm/idle_loop.atk16
+++ b/resources/asm/idle_loop.atk16
@@ -1,10 +1,4 @@
-@opt stack_pointer RG
-@opt csr_scratch RH
-@use ext_std:*
-
-; bootstrap code (must be called to setup mandatory data)
-; will jump to label main
-@include bootstrap
+@include %bootstrap
@label main
jpi main
diff --git a/resources/asm/tpu.atk16 b/resources/asm/tpu.atk16
index 1278f71..258390e 100644
--- a/resources/asm/tpu.atk16
+++ b/resources/asm/tpu.atk16
@@ -1,4 +1,4 @@
-@include bootstrap
+@include %bootstrap
@label main
ldi vt_gr_mode_addr RA
diff --git a/test/e2e/bootstrap.atk16 b/test/e2e/bootstrap.atk16
deleted file mode 100644
index 9b024e6..0000000
--- a/test/e2e/bootstrap.atk16
+++ /dev/null
@@ -1,78 +0,0 @@
-@let SP RH
-
-; vector table fields
-@let vector_table 0x10
-@let vt_ISR0 0x10 ; ISR0
-@let vt_ISR1 0x11 ; ISR1
-@let vt_ISR2 0x12 ; ISR2
-@let vt_ISR3 0x13 ; ISR3
-@let vt_stack_addr 0x14 ; Stack address
-@let vt_term_pp_addr 0x15 ; Terminal peripheral address
-@let vt_kb_pp_addr 0x16 ; Keyboard peripheral address
-@let vt_gr_mode_addr 0x17 ; Graphics mode setting address
-@let vt_sprite_mem 0x18 ; Sprite memory address
-@let vt_text_mem 0x19 ; Text memory buffer address
-
-; memory segments
-@let stack_segment 0x8000
-@let mmio_segment 0xE000
-@let terminal_addr 0xE000
-@let keyboard_addr 0xE001
-@let gr_mode_addr 0xE002
-@let sprite_mem 0xE800
-@let text_mem 0xF800 ; to 0xFFFF
-; note: sprite memory & text memory can use the same space
-; since they are never used at the same time
-
-; graphics mode settings
-@let gr_disabled_mode 0b00
-@let gr_text_mode 0b01
-@let gr_sprite_mode 0b10
-
-@address vector_table
- keyboard_isr ; 0x10
- hlt_isr ; 0x11
- hlt_isr ; 0x12
- hlt_isr ; 0x13
- stack_segment ; 0x14
- terminal_addr ; 0x15
- keyboard_addr ; 0x16
- gr_mode_addr ; 0x17
- sprite_mem ; 0x18
- text_mem ; 0x19
-
-@label hlt_isr
- ldi 0x55 RE
- hlt
-
-@label keyboard_isr
- spu RA
- spu RB
- ldi vt_kb_pp_addr RA ; RA := Keyboard peripheral address pointer
- ldr RA RA ; RA := Keyboard peripheral address deref
- ldr RA RA ; RA := <16-bit keyboard character code> from MMIO register
- ldi vt_term_pp_addr RB ; RB := Terminal peripheral address pointer
- ldr RB RB ; RB := Terminal peripheral address deref
- str RA RB ; terminal <- character code (ASCII?)
- mov RA RE ; RE := character code (for debugging)
- spo RB
- spo RA
- rti
-@label program_segment
-
-; define short prelude that sets up vital instructions
-; NOTE: must be shorter than the vector table offset
-@address 0x0
-; set up stack pointer to point to beginning of stack segment
- ldi vt_stack_addr RA
- ldr RA SP
- jpi program_segment
-
-@address program_segment
-; set graphics mode to disabled
- ldi vt_gr_mode_addr RA
- ldr RA RA
- ldi gr_disabled_mode RB
- str RB RA
-; jump to main (user defined)
- jpi main
diff --git a/test/e2e/call_stack/run_fact.atk16 b/test/e2e/call_stack/run_fact.atk16
index 06ad59c..e0b8bf1 100644
--- a/test/e2e/call_stack/run_fact.atk16
+++ b/test/e2e/call_stack/run_fact.atk16
@@ -1,6 +1,4 @@
-; bootstrap code (must be called to setup mandatory data)
-; will jump to label main
-@include ../bootstrap
+@include %bootstrap
@include lib
@let INPUT %INPUT% ; value replaced by test driver code
diff --git a/test/e2e/call_stack/run_mul.atk16 b/test/e2e/call_stack/run_mul.atk16
index feaabe7..377e61c 100644
--- a/test/e2e/call_stack/run_mul.atk16
+++ b/test/e2e/call_stack/run_mul.atk16
@@ -1,6 +1,4 @@
-; bootstrap code (must be called to setup mandatory data)
-; will jump to label main
-@include ../bootstrap
+@include %bootstrap
@include lib
; values replaced by test driver code
diff --git a/test/e2e/emulation_speed/long_loop.atk16 b/test/e2e/emulation_speed/long_loop.atk16
index 5447256..9cafde9 100644
--- a/test/e2e/emulation_speed/long_loop.atk16
+++ b/test/e2e/emulation_speed/long_loop.atk16
@@ -1,6 +1,4 @@
-; bootstrap code (must be called to setup mandatory data)
-; will jump to label main
-@include ../bootstrap
+@include %bootstrap
@label iters
10000
diff --git a/test/e2e/fibo/fibo.atk16 b/test/e2e/fibo/fibo.atk16
index 2546f43..a817a1c 100644
--- a/test/e2e/fibo/fibo.atk16
+++ b/test/e2e/fibo/fibo.atk16
@@ -1,6 +1,4 @@
-; bootstrap code (must be called to setup mandatory data)
-; will jump to label main
-@include ../bootstrap
+@include %bootstrap
@label iters
51