From 5a0e57601a9489d9f56602e0184e722c85ffc310 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Tue, 7 Nov 2023 16:29:52 +0200 Subject: WIP tree walking compiler --- asm/test_py_src.atk16 | 235 ++++++++++++++++++++++++-------------------------- 1 file changed, 115 insertions(+), 120 deletions(-) (limited to 'asm/test_py_src.atk16') diff --git a/asm/test_py_src.atk16 b/asm/test_py_src.atk16 index af8489b..c1bf1af 100644 --- a/asm/test_py_src.atk16 +++ b/asm/test_py_src.atk16 @@ -1,165 +1,160 @@ +;; BEGIN BOOTSTRAP + @opt stack_pointer RG @opt csr_scratch RH + @use ext_std:* -@include bootstrap -@label py_consts -; 0: 0 - 0 -; 1: ('*',) - 0 -; 2: 63488 + +@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 0xE000 +@let terminal_addr 0xE000 +@let keyboard_addr 0xE001 +@let gr_mode_addr 0xE002 +@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 __STACK_POINTER + 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 + ldi 0x55 RE + 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 + +@label TEXT_MODE + 1 +@label int_0 + 23 +@label int_1 63488 -; 3: 72 +@label int_2 72 -; 4: 63489 +@label int_3 63489 -; 5: 69 +@label int_4 69 -; 6: 63490 +@label int_5 63490 -; 7: 76 +@label int_6 76 -; 8: 63491 +@label int_7 63491 -; 9: 63492 +@label int_8 + 76 +@label int_9 63492 -; 10: 79 +@label int_10 79 -; 11: None - 0 -@label atk_store - str RB RA - rsr -@label atk_enable_text_mode - set_graphics_mode gr_text_mode - rsr + @label main -; PUSH_NULL None - ldi 0 RA - spu RA -; LOAD_NAME 1 - ldi atk_enable_text_mode RA +; builtin call store [, ] + ldi int_0 RA + ldr RA RA spu RA -; PRECALL 0 -; CALL 0 - spo RA - csr RA -; POP_TOP None + spo RB spo RA -; PUSH_NULL None - ldi 0 RA - spu RA -; LOAD_NAME 2 - ldi atk_store RA - spu RA -; LOAD_CONST 2 - ldi ${py_consts + 2} RA + str RB RA +; builtin call store [, ] + ldi int_1 RA ldr RA RA spu RA -; LOAD_CONST 3 - ldi ${py_consts + 3} RA + ldi int_2 RA ldr RA RA spu RA -; PRECALL 2 -; CALL 2 spo RB spo RA - spo RC - csr RC -; POP_TOP None - spo RA -; PUSH_NULL None - ldi 0 RA - spu RA -; LOAD_NAME 2 - ldi atk_store RA - spu RA -; LOAD_CONST 4 - ldi ${py_consts + 4} RA + str RB RA +; builtin call store [, ] + ldi int_3 RA ldr RA RA spu RA -; LOAD_CONST 5 - ldi ${py_consts + 5} RA + ldi int_4 RA ldr RA RA spu RA -; PRECALL 2 -; CALL 2 spo RB spo RA - spo RC - csr RC -; POP_TOP None - spo RA -; PUSH_NULL None - ldi 0 RA - spu RA -; LOAD_NAME 2 - ldi atk_store RA - spu RA -; LOAD_CONST 6 - ldi ${py_consts + 6} RA + str RB RA +; builtin call store [, ] + ldi int_5 RA ldr RA RA spu RA -; LOAD_CONST 7 - ldi ${py_consts + 7} RA + ldi int_6 RA ldr RA RA spu RA -; PRECALL 2 -; CALL 2 spo RB spo RA - spo RC - csr RC -; POP_TOP None - spo RA -; PUSH_NULL None - ldi 0 RA - spu RA -; LOAD_NAME 2 - ldi atk_store RA - spu RA -; LOAD_CONST 8 - ldi ${py_consts + 8} RA + str RB RA +; builtin call store [, ] + ldi int_7 RA ldr RA RA spu RA -; LOAD_CONST 7 - ldi ${py_consts + 7} RA + ldi int_8 RA ldr RA RA spu RA -; PRECALL 2 -; CALL 2 spo RB spo RA - spo RC - csr RC -; POP_TOP None - spo RA -; PUSH_NULL None - ldi 0 RA - spu RA -; LOAD_NAME 2 - ldi atk_store RA - spu RA -; LOAD_CONST 9 - ldi ${py_consts + 9} RA + str RB RA +; builtin call store [, ] + ldi int_9 RA ldr RA RA spu RA -; LOAD_CONST 10 - ldi ${py_consts + 10} RA + ldi int_10 RA ldr RA RA spu RA -; PRECALL 2 -; CALL 2 spo RB spo RA - spo RC - csr RC -; POP_TOP None - spo RA -; LOAD_CONST 11 - ldi ${py_consts + 11} RA - ldr RA RA - spu RA -; RETURN_VALUE None -@label keep_alive - jpi keep_alive \ No newline at end of file + str RB RA +; builtin call asm [] + ldi 1 RA \ No newline at end of file -- cgit v1.3