The 8051 Microcontroller and Embedded

(lily) #1
Department of Computer Scien

ce and Information Engineering

National Cheng Kung University, TAIWAN
HANEL

ACCESSING MEMORYRegister Indirect Addressing Mode(cont’)


‰The advantage is that it makes accessing data dynamic rather than static as in direct addressing mode


¾Looping is not possible in direct addressing modeExample 5-4Write a program to clear 16 RAM locations starting at RAM address 60HSolution:


CLR A ;A=0MOV R1,#60H ;load pointer. R1=60HMOV R7,#16 ;load counter, R7=16
AGAIN: MOV @R1,A ;clear RAM R1 points to

INC R1 ;increment R1 pointerDJNZ R7,AGAIN ;l

oop until counter=zero
Free download pdf