ok, so which registers should i turn to? 20H and up?
Look in Section 2.0 of your datasheet. Figure 2.3 on Page 17 is a very good Register File Map that shows exactly what memory is free for you to use. There's free RAM in each bank that you can use.
To set up your variables, use cblock, like this:
Code:
cblock 0x20
d1,d2,d3,speed,speed2,temp
endc
org 0x000
...
The number after cblock tells the assembler where to start putting variables. As Mike-K8LH says, stay out of the SFR's or you can expect your code to do nothing at all.
Each variable is one byte. There are ways to do multi-byte vars too.
If, for neatness or other reason, you don't want them all on one line, you can do this kind of thing too:
Code:
cblock 0x20
d1,d2,d3,speed,speed2,temp
var1,var2,var3,var4,var5
endc
Note no commas at end of rows.
but the program itself is ok?
I haven't looked at it too much detail, but a quick cursory look seems ok. Unless you tell us your oscillator speed there's no way to tell you whether that delay is the correct length or not. When programming in assembler I often just use the to save time.
OH! Also, when you're posting source code, be sure to either click the
# icon before pasting your code, or type [co
de] before your code and [/code] after it. These tags tell the web-site software to leave the formatting (indentation, etc.) of your source code alone (see my two code blocks above and one below). Makes it
MUCH more readable and makes it much more likely that other people will actually look at it and try to help you. If it's an unformatted unreadable mess a lot of people won't bother looking at it.
Here's your original code, cleaned up and with a cblock. I haven't tested it, but it appears correct. Note the use of banksel directives instead of the (IMHO) mildly cryptic RP0 bit twiddling some people use.
Code:
#include <p16f877a.inc>
__CONFIG _HS_OSC & _LVP_OFF & _WDT_OFF
cblock 0x20
CounterA,CounterB,CounterC
endc
org 0x000
banksel TRISC ;bank 1
movlw b'00000000' ;portc all outs
movwf TRISC
banksel PORTC ;bank 0
start bsf PORTC,0 ;RC0 high
call delay
bcf PORTC,0 ;RC0 low
call delay
goto start
delay movlw 0x06
movwf CounterC
movlw 0x13
movwf CounterB
movlw 0xad
movwf CounterA
loop decfsz CounterA,1
goto loop
decfsz CounterB,1
goto loop
decfsz CounterC,1
goto loop
return
end