
520 EMBEDDED SYSTEMS
ORG 0
MOV R1,45H ;take data from RAM address 45H
MOV R3,#8 ;R3 to act as a counter for 8 bits
MOV R2,#0 ;R2 = 0
MOV A,R1 ;copy R1 to A
ROT: RLC A ;rotate left
JNC COUNT ;if C = 0, jump to COUNT
INC R2 ;since C = 1, increment R2
COUNT: DJNZ R3,ROT ;decrement until R3 = 0
HERE: SJMP HERE
END
13.11 | Subroutines (Procedures)
All the programs that we have written are straightforward, in the sense that control fl ows
sequentially from one instruction to the next, and a change in the sequence in which a
program in executed, is changed only on encountering a JUMP instruction.
But there is another way by which the execution ...