Here is a couple of examples of direct and indirect addressing..
MOV R0,#30H ;..... R0 < = 30H ( direct.. The number 0x30 is placed in A )
MOV A,@R0 ;...... A < = 40H ( indirect , using R0.. the data IN R0 is placed in A )
MOV R1,A ;...... R1 < = 40H ( direct.... The number 0x40 is placed in R1 )
MOV B,@R1 ;..... B < = 10H ( indirect... The number IN R1 is placed in B )
MOV @R1,P1 ;..... RAM (40H) < = 0CAH ( indirect )
MOV P2,P1 ;...... P2 #0CAH ( direct )
The 8051 normally runs with a 12mhz clock.... 12 cycles per instruction... 9 instructons + 2 for the jump... 11 cycles or 11μS per loop... The LED's will appear to be doing nothing, as they are off more than on...
The human eye will need 100mS to see the LED transitions... ( 10 pulses per second )
You will need to write a delay routine ( one in the first example we did ) to slow the action a bit...
The 8051 normally runs with a 12mhz clock.... 12 cycles per instruction... 9 instructons + 2 for the jump... 11 cycles or 11μS per loop... The LED's will appear to be doing nothing, as they are off more than on...
The human eye will need 100mS to see the LED transitions... ( 10 pulses per second )
You will need to write a delay routine ( one in the first example we did ) to slow the action a bit...
Ian, sorry to say that I cant do anything because i cant manage to know or understand the codes. what does the code will act in physically.
what I understand that the post 92 is showing. or here it is:
What's not to understand... this is as simple as it gets...
Code:
org 0000h
sjmp start ; goto main loop called start
start:
clr P1.0 ; bit 0 of PORT1 is cleared
clr P1.3 ; bit 3 of PORT1 is cleared
setb P1.0 ; bit 0 of PORT1 is set
setb P1.3 ; bit 3 of PORT1 is set
clr P1.2 ; bit 2 of PORT1 is cleared
setb P1.2 ; bit 2 of PORT1 is set
clr P1.1 ; bit 1 of PORT1 is cleared
setb P1.1 ; bit 1 of PORT1 is set
setb P1.2 ; bit 2 of PORT1 is set
sjmp start ; go back to start and do it again..
end
You can place delays after changes in port status like this..
Code:
org 0000h
sjmp start ; goto main loop called start
start:
clr P1.0 ; bit 0 of PORT1 is cleared
clr P1.3 ; bit 3 of PORT1 is cleared
lcall Delay
setb P1.0 ; bit 0 of PORT1 is set
setb P1.3 ; bit 3 of PORT1 is set
lcall Delay
clr P1.2 ; bit 2 of PORT1 is cleared
lcall Delay
setb P1.2 ; bit 2 of PORT1 is set
lcall Delay
clr P1.1 ; bit 1 of PORT1 is cleared
lcall Delay
setb P1.1 ; bit 1 of PORT1 is set
setb P1.2 ; bit 2 of PORT1 is set
lcall Delay
sjmp start ; go back to start and do it again..
Delay: mov R1,#010h
Dy1: mov R2,#010h
Dy2: djnz R2,Dy2
djnz R1,Dy1
ret
end