fox32rom: Add copy_string

This commit is contained in:
Ry 2022-04-23 16:47:17 -07:00
parent 408bd6c91d
commit bcfeac816b
3 changed files with 29 additions and 2 deletions

View File

@ -58,8 +58,9 @@ write_sector: jmp [0xF0045004]
; memory copy/compare jump table ; memory copy/compare jump table
copy_memory_bytes: jmp [0xF0046000] copy_memory_bytes: jmp [0xF0046000]
copy_memory_words: jmp [0xF0046004] copy_memory_words: jmp [0xF0046004]
compare_memory_bytes: jmp [0xF0046008] copy_string: jmp [0xF0046008]
compare_memory_words: jmp [0xF004600C] compare_memory_bytes: jmp [0xF004600C]
compare_memory_words: jmp [0xF0046010]
; event types ; event types
const EVENT_TYPE_MOUSE_CLICK: 0x00000000 const EVENT_TYPE_MOUSE_CLICK: 0x00000000

View File

@ -155,6 +155,7 @@ get_rom_version:
#include "overlay.asm" #include "overlay.asm"
#include "panic.asm" #include "panic.asm"
#include "ryfs.asm" #include "ryfs.asm"
#include "string.asm"
#include "vsync.asm" #include "vsync.asm"
@ -227,6 +228,7 @@ get_rom_version:
org.pad 0xF0046000 org.pad 0xF0046000
data.32 copy_memory_bytes data.32 copy_memory_bytes
data.32 copy_memory_words data.32 copy_memory_words
data.32 copy_string
data.32 compare_memory_bytes data.32 compare_memory_bytes
data.32 compare_memory_words data.32 compare_memory_words

24
string.asm Normal file
View File

@ -0,0 +1,24 @@
; copy string from source pointer to destination pointer
; if the source and destination overlap, the behavior is undefined
; inputs:
; r0: pointer to source
; r1: pointer to destinaton
; outputs:
; none
copy_string:
push r0
push r1
push r2
copy_string_loop:
mov.8 r2, [r0]
mov.8 [r1], r2
inc r0
inc r1
cmp.8 r2, 0
ifnz jmp copy_string_loop
pop r2
pop r1
pop r0
ret