Answer :- The code has been written below-
CountLoop EQU 0x00 ;store value 0 in counter variable
Count1 EQU 0x00 ;store value 0 in counter variable
MOVLW 0x00 ;W = 0
MOVWF FSR ;FSR = 0
Loop1: ;label name Loop1
MOVF INDF, W ;read location value stored in FSR and keep in W, so W
= value at the location in FSR
ANDLW 0xFF ;W = W & 0xFF
BTFSC STATUS, 2 ;check if zero flag is clear then skip next
statement
GOTO CountZero ;goto label CountZero
Back1:
INCF FSR ;increase the FSR value to next location
INCFSZ CountLoop ;increment the counter, skip next line if
zero
GOTO Loop1 ;goto Loop1
Here : GOTO Here ;end of the code
CountZero:
INCF Count1 ;increment the counter value
MOVF Count1, W ;set W = counted zero value
GOTO Back1 ;go to label named as Back1
Get Answers For Free
Most questions answered within 1 hours.