fox32rom: Add compare_string
This commit is contained in:
parent
bcfeac816b
commit
c078c2b917
|
@ -61,6 +61,7 @@ copy_memory_words: jmp [0xF0046004]
|
||||||
copy_string: jmp [0xF0046008]
|
copy_string: jmp [0xF0046008]
|
||||||
compare_memory_bytes: jmp [0xF004600C]
|
compare_memory_bytes: jmp [0xF004600C]
|
||||||
compare_memory_words: jmp [0xF0046010]
|
compare_memory_words: jmp [0xF0046010]
|
||||||
|
compare_string: jmp [0xF0046014]
|
||||||
|
|
||||||
; event types
|
; event types
|
||||||
const EVENT_TYPE_MOUSE_CLICK: 0x00000000
|
const EVENT_TYPE_MOUSE_CLICK: 0x00000000
|
||||||
|
|
1
main.asm
1
main.asm
|
@ -231,6 +231,7 @@ get_rom_version:
|
||||||
data.32 copy_string
|
data.32 copy_string
|
||||||
data.32 compare_memory_bytes
|
data.32 compare_memory_bytes
|
||||||
data.32 compare_memory_words
|
data.32 compare_memory_words
|
||||||
|
data.32 compare_string
|
||||||
|
|
||||||
org.pad 0xF004F000
|
org.pad 0xF004F000
|
||||||
standard_font_width:
|
standard_font_width:
|
||||||
|
|
37
string.asm
37
string.asm
|
@ -1,3 +1,5 @@
|
||||||
|
; string copy/compare routines
|
||||||
|
|
||||||
; copy string from source pointer to destination pointer
|
; copy string from source pointer to destination pointer
|
||||||
; if the source and destination overlap, the behavior is undefined
|
; if the source and destination overlap, the behavior is undefined
|
||||||
; inputs:
|
; inputs:
|
||||||
|
@ -22,3 +24,38 @@ copy_string_loop:
|
||||||
pop r1
|
pop r1
|
||||||
pop r0
|
pop r0
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; compare string from source pointer with destination pointer
|
||||||
|
; inputs:
|
||||||
|
; r0: pointer to source
|
||||||
|
; r1: pointer to destinaton
|
||||||
|
; outputs:
|
||||||
|
; Z flag
|
||||||
|
compare_string:
|
||||||
|
push r0
|
||||||
|
push r1
|
||||||
|
compare_string_loop:
|
||||||
|
; check if the strings match
|
||||||
|
cmp.8 [r0], [r1]
|
||||||
|
ifnz jmp compare_string_not_equal
|
||||||
|
|
||||||
|
; if this is the end of string 1, then this must also be the end of string 2
|
||||||
|
; the cmp above alredy ensured that both strings have a null-terminator here
|
||||||
|
cmp.8 [r0], 0
|
||||||
|
ifz jmp compare_string_equal
|
||||||
|
|
||||||
|
inc r0
|
||||||
|
inc r1
|
||||||
|
jmp compare_string_loop
|
||||||
|
compare_string_not_equal:
|
||||||
|
; Z flag is already cleared at this point
|
||||||
|
pop r1
|
||||||
|
pop r0
|
||||||
|
ret
|
||||||
|
compare_string_equal:
|
||||||
|
; set Z flag
|
||||||
|
mov r0, 0
|
||||||
|
cmp r0, 0
|
||||||
|
pop r1
|
||||||
|
pop r0
|
||||||
|
ret
|
||||||
|
|
Loading…
Reference in New Issue
Block a user