From 8998bd04c94da08dc49ab62007da5604d53895c3 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Mon, 1 May 2023 13:50:52 +0100 Subject: Initial import --- example.asm | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 example.asm (limited to 'example.asm') diff --git a/example.asm b/example.asm new file mode 100644 index 0000000..6d4521e --- /dev/null +++ b/example.asm @@ -0,0 +1,125 @@ +; +; example.asm for TR8 +; +.org 0 + +; ; copy 16K from 0x0000 to 0xbf00 +; ; +; start: +; ld a, 0 +; ld b, 0xbf +; ld x, 0 +; ld y, 0x40 +; loop: +; push y +; ld y, [a : x] +; ld [b : x], y +; pop y +; inc x +; bno +; jmp loop +; inc a +; inc b +; dec y +; bnz +; jmp loop +; + ld b, 15 + call fill + + halt +; +; ; void copy(void *dst, void *src, uint16_t size) +; ; size = 0x1000 +; ; src = 0 +; ; dst 0xbf00 +; ld a, 0x10 +; push a +; ld a, 0 +; push a +; push a +; push a +; ld a, 0xbf +; push a +; ld a, 0 +; push a +; call copy +; pop a +; pop a +; pop a +; pop a +; pop a +; pop a +; halt + + ; fill frame-buffer with a color in reg b +fill: + ld a, 0xbf + ld x, 0 + ld y, 0x40 +fill_loop: + ld [a : x], b + inc x + bno + jmp fill_loop + inc a + dec y + bnz + jmp fill_loop + ret + + ; void copy(void *dst, void *src, uint16_t size) + ; + ; using C calling convention with the stack + ; not used, but return value in a (8-bit), a: x (16-bit) +; copy: +; ld x, [sp + 6] +; ld a, [sp + 7] ; size a:x +; +; ; local variable +; push a +; push x +; +; ld y, [sp + 4] +; ld b, [sp + 5] ; dst b:y +; ld x, [sp + 6] +; ld a, [sp + 7] ; src a:x +; copy_loop: +; ; copy byte from a:x to b:y +; push x +; ld x, [a : x] +; ld [b : y], x +; pop x +; +; ; inc a:x +; inc x +; bo +; inc a +; +; ; inc b:y +; inc y +; bo +; inc b +; +; ; dec local var size +; push a +; push x +; ld x, [sp + 2] +; ld a, [sp + 3] +; dec x +; bo +; dec a +; ld [sp + 2], x +; ld [sp + 3], a +; or x, a +; pop x +; pop a +; +; bnz +; jmp copy_loop +; +; pop x +; pop x ; free local var +; ret +; +; -- cgit v1.2.3