aboutsummaryrefslogtreecommitdiffstats
path: root/atk16_asm/builtin_asm/std_mem.atk16
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2024-04-13 16:23:36 +0300
committerJan Tuomi <jan@jantuomi.fi>2024-04-13 16:23:36 +0300
commit374feaf304df4fababf82af72776e8e98df00be8 (patch)
treee9eb78b26d521b88826abccc01c3e2e7e7aa0b1f /atk16_asm/builtin_asm/std_mem.atk16
parent3f9f7eefb9d0836ec53a08e311219f7f497517c7 (diff)
WIP peripherals
Diffstat (limited to 'atk16_asm/builtin_asm/std_mem.atk16')
-rw-r--r--atk16_asm/builtin_asm/std_mem.atk1619
1 files changed, 19 insertions, 0 deletions
diff --git a/atk16_asm/builtin_asm/std_mem.atk16 b/atk16_asm/builtin_asm/std_mem.atk16
new file mode 100644
index 0000000..4c6a455
--- /dev/null
+++ b/atk16_asm/builtin_asm/std_mem.atk16
@@ -0,0 +1,19 @@
+@label memset
+ ; sets a specified number of words in memory to a specified value
+ ; parameters: RA = offset (offset in memory to start at)
+ ; RB = n (number of words to set)
+ ; RC = val (value to set the words to)
+ ; returns: void
+ stack_stash RD RE
+ ldi 0 RD ; RD := i (counter), initially 0
+@label memset_loop
+ subi RB RD RE ; RE := n – i (unused value)
+ bri zero memset_done ; exit the loop
+
+ add RA RD RE ; RE := RA + i (address of the word to set)
+ str RC RE ; set the word at address RE to value in RC
+
+ inc RD ; i := i + 1
+@label memset_done
+ stack_restore RD RE
+ return