Department of Computer Scien
ce and Information Engineering
National Cheng Kung University, TAIWAN
HANEL
ROTATE INSTRUCTIONAND DATA
SERIALIZATION
Rotating through Carry(cont’)
RLC A ;rotate left through carryIn RLC A
¾Bits are shifted from right to left ¾They exit the MSB and enter the carry flag, and the carry flag enters the LSB
MSB LSB
CY
Write a program that finds the number of 1s in a given byte.
MOV R1,#0MOV R7,#8 ;count=08MOV A,#97H
AGAIN: RLC A
JNC NEXT ;check for CYINC R1 ;if CY=1 add to count
NEXT: DJNZ R7,AGAIN