You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Faster _streq routine definition and original _streq routine in string.s #125
;assuming sourcestring to be compared is loaded in a0 and the string to be compared with in a1
also works by null byte length source or destination strings all thanks to the Scc instructions
;possible speedup by comparing (a0)+,(a1)+ directly, just had this idea and need to check this further
; including _streq.txt since formatting gets lost in github or how can you set tabs?
_streq:
moveq #0,d0 ; D0 = 0; also sets Z=1 (needed to prime SNE below)
_streq_loop:
move.b (a0)+,d1 ; load next byte from string 1; Z=1 if NUL
sne.b d0 ; D0.b = $FF if previous cmp found NOT equal (Z=0)
;$00 if previous cmp found equal (Z=1)
; (first iteration: Z came from MOVEQ, so D0.b=0)
cmp.b (a1)+,d1 ; compare string1 byte with string2 byte; sets Z
dbne d0,_streq_loop ; if chars differ (Z=0, NE true): fall through
; if chars match (Z=1, NE false): decrement D0.w,
; branch if D0.w != -1 (SNE having set D0.b to $FF
; gives D0.w=$00FF=255, so 255 iterations until -1)
seq.b d0 ; D0.b = $FF if last compare was equal (Z=1), else $00
ext.l d0 :no need for extb.l, ext.l will do its job just fine!!
rts
Activity