fox32rom: Add string_length

This commit is contained in:
Ry 2022-05-01 17:59:54 -07:00
parent 3ec126f877
commit 77ee645f7d
2 changed files with 22 additions and 0 deletions

View File

@ -62,6 +62,7 @@ copy_string: jmp [0xF0046008]
compare_memory_bytes: jmp [0xF004600C]
compare_memory_words: jmp [0xF0046010]
compare_string: jmp [0xF0046014]
string_length: jmp [0xF0046018]
; event types
const EVENT_TYPE_MOUSE_CLICK: 0x00000000

View File

@ -59,3 +59,24 @@ compare_string_equal:
pop r1
pop r0
ret
; get the length of a string
; inputs:
; r0: pointer to null-terminated string
; outputs:
; r0: length of the string, not including the null-terminator
string_length:
push r1
mov r1, 0
string_length_loop:
; check if this is the end of the string
cmp.8 [r0], 0
ifz jmp string_length_end
inc r0
inc r1
jmp string_length_loop
string_length_end:
mov r0, r1
pop r1
ret