Cblock assigns an incremental constant number to each defined member inside it. This infact are the ram locations for that member/variable.
In your case, suppose RAM starts from 0x20 then
d1 will be located at RAM address 0x20
d2 will be located at RAM address 0x21
d3 will be located at RAM address 0x22
d4 will be located at RAM address 0x23
$+2 means address greater by 2 words than the current instruction address.
$ means address of the current instruction being executed.
but If you can explain this part pleaz >> i need to know when ($+2) is come what the next instruction will be executed in this part (Delay_0 or decfsz d2, f )
Code:
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto $+2
decfsz d4, f
goto Delay_0
but If you can explain this part pleaz >> i need to know when ($+2) is come what the next instruction will be executed in this part (Delay_0 or decfsz d2, f )
Delay_0
decfsz d1, f goto $+2 decfsz d2, f goto $+2 decfsz d3, f goto $+2 decfsz d4, f goto Delay_0
look to the code below .... the delay code of 4 second is in the red color.... and the main code in the black .... when insert the delay code to the main code and convert it to the Hex file ... there is no error and the process is success ...... ,and when loaded to the pic the loading is success but the code not opreate well and the led on the port B0 remain on .... and the led on the port B2 is remain off
can any body tell me .... if there are errors in my code ... i'm using picf84a and loaded many code before and are operating very well without errors
processor 16f84a
include <p16f84.inc>
__config _RC_OSC & _WDT_OFF & _PWRTE_ON
; Program
cblock
d1
d2
d3
d4
endc
org 0 ; start at address 0
; At startup, all ports are inputs.
loop
; Set Port B to all outputs.
movlw 0x00 ; w := binary 00000000
tris PORTB ; copy w to port B control reg
; Put a 1 in the lowest bit of port B.
movlw 0x01 ; w := binary 00000001
movwf PORTB ; copy w to port B itself
call Delay
movlw 0x04
movwf PORTB
call Delay ; Stop by going into an endless loop
goto loop