; RAM registers
ram_start EQU 0x0c
dcnt0 EQU ram_start+1 ; delay counter 0
dcnt1 EQU ram_start+2 ; delay counter 1
dcnt2 EQU ram_start+3 ; delay counter 2
hello guys! Can anyone tell me about the RAM_START codes? What is the operation RAM_START+1 to 4?? RAM_START operation starts at 0x0c? is that correct?Sorry guys..i'm new at assembly.. Thanks guys!!
Code:; RAM registers ram_start EQU 0x0c dcnt0 EQU ram_start+1 ; delay counter 0 dcnt1 EQU ram_start+2 ; delay counter 1 dcnt2 EQU ram_start+3 ; delay counter 2
what this is doing is defining the ram locations for dcnt0, dcnt1, dcnt2, etc...
RAM_START is 0x0c, therefore, RAM_START+1 is 0x0d... so anytime you use dcnt0, it will use RAM location 0x0d, and 0x0e for dcnt1, etc...
they are floating their declarations instead of using absolutes because if they port this to another micro, that has a RAM that starts at 0x60, then they only have to change one definition, RAM_START, and all the others will be automatically redefined. If he'd used absolutes (dcnt0 = 0x0d) then he'd have to change all his variable declarations as well.
I've no idea what 'floating' means in this context?.
But a far better way is to use Cblock.
"C Block"??? you were in prison????don't just tell him, show an example of 'how you would use CBLOCK'... like he said, he's new to assembly.
Another question guys! is "#define" an assembly code? or C? here's an example guys..thank you!
Code:#define LED00 movlw 0 ;1st Digit LED #define LED01 movlw 1 ;2nd Digit LED #define LED02 movlw 3 ;3rd Digit LED #define LED03 movlw 7
Neither, it's an assembler directive - not code at all (think of it as a text 'search and replace').
dcnt0 EQU ram_start+1
#define LED00 movlw 0
cblock 0x20 ;start of general purpose registers
count ;used in looping routines
count1 ;used in delay routine
counta ;used in delay routine
countb ;used in delay routine
tmp1 ;temporary storage
tmp2
templcd ;temp store for 4 bit mode
templcd2
endc
LED00 EQU movlw 0
tmptr EQU readbuf_end
tmbyte EQU readbuf_end+1
keytable
movf keycode, W
addwf PCL, F
dt 0x60
dt "123a"
dt "456b"
dt "789c"
dt "*0#d"
keyscan
clrf keycode
movlw 4
movwf rowcnt
movlw 0xfe
tris PORTA
rowscan movlw 0xa0
call udelay
swapf PORTB, W
movwf colstatus
movlw 4
movwf colcnt
colscan incf keycode, F
rrf colstatus, F
btfss STATUS, C
goto keytable
decfsz colcnt, F
goto colscan
bsf STATUS, C
bsf STATUS, RP0
rlf TRISA, F
bcf STATUS, RP0
decfsz rowcnt, F
goto rowscan
retlw 0
;-----COUNT UP SWITCH---------------
Up_Switch
Delay4
btfsc PORTA, 0
goto Exit1
movf COUNT, W
xorlw 12
btfsc STATUS, 2
goto Exit1
incf COUNT
Delay4
movlw 1
movwf COUNT5
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?