Is there a way to increment the memory in the 8051 architecture?
for example:
Memory Slot:
mov 0x71, #0x01
mov 0x72, #0x02
mov 0x73, #0x03
is there a way to in a for loop say
mov 0x71, A
do something;
mov 0x72, A
do something;
in a for loop?
in java you just do the simple for(int i = 0; i < variable; i++)
but I dont know how to do that in 8051 architecture.
Sure, there are a number of ways you can do this. I would probably use DJNZ or CJNE instruction depending on the surrounding code.
;Load your control variable into B. From a table, GPIO, etc.
MOV B,#3H
;Build your loop. This is basically a Do While loop.
;int i=0, (really a byte since 8 is 8-bit)
CLR A
;Start of the loop, notice this is AFTER the CLR op
FN_LOOP:
;Do something...
;i++
INC A
;i < variable. Stops when A == B
CJNE A,B,FN_LOOP
;Rest of your code
I would recommend reading up on addressing modes in assembly as well. That knowledge is essential to reading assembly instruction set documentation.