fox32rom: Add string_length
This commit is contained in:
parent
3ec126f877
commit
77ee645f7d
|
@ -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
|
||||
|
|
21
string.asm
21
string.asm
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user