0

尝试计算任何给定数组的零个数

            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

但是第二个 CMP D0,D1 没有激活 BGT UPDATEF 来存储更大计数器的值

4

0 回答 0