;BCMP.ASM ; ; If both source and dest are on longword boundries, and if the byte ; count is a multiple of 4, then use longword operations. ; ; if byte count < 16 then just use byte operations ; ; BCMP(p1,p2,n) return 0=failed, 1=compare ok xdef _bcmp _bcmp: movem.l 4(A7),A0/A1 ;A0 = ptr1, A1 = ptr2 move.l 12(A7),D1 ;# bytes andi.b #3,15(A7) ;# bytes multiple of 4? bne onbyte andi.b #3,7(A7) ;ptr1 on lwb? bne onbyte andi.b #3,11(A7) ;ptr2 on lwb? bne onbyte lsr.l #2,D1 ;YES, LONG COMPARE LOOP clr.l D0 ;default return. Also sets Z flag bra dropl loopl cmpm.l (A0)+,(A1)+ dropl dbne.w D1,loopl bne end sub.l #$10000,D1 bpl loopl addq.l #1,D0 ;return TRUE rts onbyte clr.l D0 ;default return. Also sets Z flag bra dropb loopb cmpm.b (A0)+,(A1)+ ;BYTE COMPARE dropb dbne.w D1,loopb ;until count exhausted or compare failed bne end sub.l #$10000,D1 ;for buffers >65535 bpl loopb ;branch to loop because D0.W now is FFFF addq.l #1,D0 ;return TRUE end rts