我正在编写一个子程序来计算 wreg 中设置的位数,但是在到达子程序末尾的 return 语句时,它只是无休止地重复 return 语句。我是 PIC 和组装的新手,所以我确信我刚刚做了一些愚蠢的事情,但我还没有能够解决它。任何帮助将不胜感激。
这是我的代码:
COUNT equ 0x00
NUMBER equ 0x01
BITS equ 0x02
;bitcounter subprogram counts the number of set bits in a byte
BITCOUNTER:
Loop1 rlcf NUMBER,f ;rotates one bit of number into carry flag, store rotated number
btfsc STATUS, C ;skips next line if carry is clear
incf COUNT, f ;add one to count, store in count
bcf STATUS, C ;clear carry flag
decfsz BITS
goto Loop1
movf COUNT, 0 ; put bit count into W register
return
START
movlw 0x0008
movwf BITS
movlw 0xF2
movwf NUMBER ;stores input as "number"
call BITCOUNTER
end