Assembly 68k - CMP not working as expected

146 Views Asked by At

Trying to calculate the number of zero for any given array

            ORG     $8000
START       MOVEA.L #V0,A0
COUNTERT    CLR     D0
COUNTERF    CLR     D1      
RIEMP       MOVE    NELEM,D2

LOOP        CMP     #0,(A0)+
            BEQ     COUNT
            CMP     D0,D1
            BGT     UPDATEF
CKR         ADD     #-1,D2
            BEQ     STORE   
            BRA     LOOP

COUNT       ADDI    #1,D0
            BRA     LOOP

UPDATEF     MOVE    D0,D1
            CLR     D0
            BRA     CKR

STORE       MOVE    D1,LZ
FINE        JMP     FINE

            ORG     $8200
V0          DC.W    1,0,0,1,0,-3,1
V1          DC.W    0,-3,0,0,0,0,2
V2          DC.W    1,0,-1,1,0,-3,2
V3          DC.W    1,5,--1,2,4,-3,1
NELEM       DC.W    7

            ORG     $8300
LZ          DS.W    1

            END     START

But the second CMP D0,D1 doesn't activate the BGT UPDATEF to store the value of the greater counter

0

There are 0 best solutions below