Re: A86: comparing strings
[Prev][Next][Index][Thread]
Re: A86: comparing strings
There are two procedures to compare strings: first tests if strings are
equal, second tests, which is "greater"
;---------------------------------------------------------------------------
;Compare strings with addresses given in HL and DE
;Returns: A=1 if strings equal, otherwise 0
IS_DE_HL_STR_EQ:
push de
push hl
push bc
IDHSE_Loop:
ld a, (de)
cp (hl)
jr nz, IDHSE_Not
inc de
inc hl
djnz IDHSE_Loop
ld a, 1 ;equal
jr IDHSE_End
IDHSE_Not:
xor a ;not equal
IDHSE_End:
pop bc
pop hl
pop de
ret
;---------------------------------------------------------------------------
;is string with addr in DE is greater than string with addr in HL ?
;If greater then A=1, otherwise A=0
IS_DE_GR_HL_STR:
ld a, (de)
cp (hl)
jr nz, IDGHS_Test
inc de
inc hl
djnz IS_DE_GR_HL_STR
jr IDGHS_Not
IDGHS_Test:
jr c, IDGHS_Not
ld a, 1
ret
IDGHS_Not:
xor a
ret
Follow-Ups:
References: