diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2024-04-19 09:55:30 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2024-04-19 09:55:30 +0300 |
| commit | fad7d9ff1b7f1cc736d775e03096a398a7e9719a (patch) | |
| tree | 58261f1ee8d421c21e7ea81abc397a4720482217 /resources/asm/monitor_macros.py | |
| parent | 0a2b1cad27307fde058ce30d5cd8685c336e987a (diff) | |
WIP monitor
Diffstat (limited to 'resources/asm/monitor_macros.py')
| -rw-r--r-- | resources/asm/monitor_macros.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/resources/asm/monitor_macros.py b/resources/asm/monitor_macros.py new file mode 100644 index 0000000..e753996 --- /dev/null +++ b/resources/asm/monitor_macros.py @@ -0,0 +1,29 @@ +from atk16_asm.asm_ops import * + +expansions: dict[str, Callable[..., ExpandResult]] = {} +def register_macro(func): + expansions[func.__name__] = func + return func + +@register_macro +def m_newline(r1: str, r2: str) -> ExpandResult: + return [ + *expand_ldi("text_cursor_p", r1), + *expand_ldr(r1, r1), + *expand_ldr(r1, r2), + *expand_slri(r2, "6", r2), # cursor = cursor / 64 + *expand_addi(r2, "1", r2), # cursor = cursor + 1 + *expand_slli(r2, "6", r2), # cursor = cursor * 64 + *expand_str(r2, r1), + ] + +@register_macro +def m_put_char(char_r: str, r1: str, r2: str) -> ExpandResult: + return [ + *expand_ldi("text_cursor_p", r1), + *expand_ldr(r1, r1), + *expand_ldr(r1, r2), + *expand_str(char_r, r2), + *expand_addi(r2, "1", r2), + *expand_str(r2, r1), + ] |
