aboutsummaryrefslogtreecommitdiffstats
path: root/atk16_ast_walking_compiler/ast_compiler_bootstrap.atk16
diff options
context:
space:
mode:
Diffstat (limited to 'atk16_ast_walking_compiler/ast_compiler_bootstrap.atk16')
-rw-r--r--atk16_ast_walking_compiler/ast_compiler_bootstrap.atk1674
1 files changed, 74 insertions, 0 deletions
diff --git a/atk16_ast_walking_compiler/ast_compiler_bootstrap.atk16 b/atk16_ast_walking_compiler/ast_compiler_bootstrap.atk16
new file mode 100644
index 0000000..b38e5f5
--- /dev/null
+++ b/atk16_ast_walking_compiler/ast_compiler_bootstrap.atk16
@@ -0,0 +1,74 @@
+;; BEGIN BOOTSTRAP
+
+@use ext_std:*
+
+@let sp RH ; stack pointer (points to empty slot at top of stack)
+@let fp RG ; frame pointer (points to base of currently active frame)
+
+@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
+
+@let stack_segment 0x8000
+@let mmio_segment 0xE7F0
+@let terminal_addr 0xE7F0
+@let keyboard_addr 0xE7F1
+@let gr_mode_addr 0xE7F2
+@let sprite_mem 0xE800
+@let text_mem 0xF800
+
+@let gr_disabled_mode 0b00
+@let gr_text_mode 0b01
+@let gr_sprite_mode 0b10
+
+@address 0x0
+ ldi vt_stack_addr RA
+ ldr RA SP
+ mov SP FP
+ jpi program_segment
+
+@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
+ hlt
+
+@label keyboard_isr
+ spu RA
+ spu RB
+ ldi vt_kb_pp_addr RA
+ ldr RA RA
+ ldr RA RA
+ ldi vt_term_pp_addr RB
+ ldr RB RB
+ str RA RB
+ spo RB
+ spo RA
+ rti
+
+@label program_segment
+ ldi vt_gr_mode_addr RA
+ ldr RA RA
+ ldi gr_disabled_mode RB
+ str RB RA
+
+ jpi main
+
+;; END BOOTSTRAP \ No newline at end of file