i've just started programming the pic - i've got the led's lit up
etc etc now moving on to bigger & better things..
a couple of questions regarding common practice :
- i started off assigning my own registers just using
CTR EQU 20h
what i meant was i wanted to use address 20h
now is it usual to use the 'DS' command to do this
kind of thing? i.e.
CTR DS 1
CTR2 DS 1
i'm kinda unsure about the direct/indirect addressing..
- say i want a small buffer (i.e. maybe 12/16 bits) - i do this
BUFFER DS 16
now how do i get at this buffer? i know i can do BUFFER+<offset>
but i want to use 'a variable' for the offset, increment it,
etc etc as i would in a high level language...
i thought of having another memory location holding a 'pointer'
to my buffer and then incrementing/decrementing this - but
trying to implement this seems kinda unnecessarily complex..
any tips? i guess i'm still thinking high level language...
ISE III BEng
Incremental Sanity Erosion at Imperial College
There is a register called the FSR (I think that stands for File Select
Register). You load the address of the start of the buffer into this
register. Then you read register 0 (I think it is called INDF) this
register will now hold the value of the register pointed to by the FSR.
Thus you would do something like this:
movlw Buffer ;this places the address of you 'Buffer' into w
movwf FSR ;place the address into FSR
Now you can work with the buffer:
movfw INDF ;This will put the value at Buffer into w
incf FSR ;Point to buffer+1
clrf INDF ;clear the data at Buffer+1
You can increment, decrement, add to & subtract from the FSR like with any
I often use this method when I have a piece of code that performs a similar
function of a lot of registers.
Here is an example of how I define my variables:
SaveW ;01 holds W register durring interrupt
SaveS ;02 holds Status register durring interrupt
SaveFSR ;03 Holds copy of FSR durring interrupt
T1 ;04 Timer values
I like using this method because if I want to add a variable say between
SaveS and SaveFSR (it makes more visual sense for whatever reason) the I
don't have to renumber all the variables. The compiler will renumber
consecutively them from 0ch until it reaches ENDC.
As for setting up the buffer, I have not had to do that so I couldn't tell
you for sure but I think you are right.
FROST - Electronic Design, Manufacture & Consulting.
Tel: +27 331 965125
Cel: +83 2275216
Pietermaritzburg, South Africa
Products: Medical Motivational equipment
Timers for food processing
Random number generator
PS Anyone looking for someone in the hardware/software development fields,
I am available. I intend leaving South Africa for the West coast of the US
early this year.
>I often use this method when I have a piece of code that performs a similar
>function of a lot of registers.
>Here is an example of how I define my variables:
> CBLOCK 0ch
> SaveW ;01 holds W register durring interrupt
> SaveS ;02 holds Status register durring interrupt
> SaveFSR ;03 Holds copy of FSR durring interrupt
> T1 ;04 Timer values
> T2 ;05
> T3 ;06
> T4 ;07
Could this be analogous to setting up an object oriented procedure ?
Some say there is no magic but, all things begin with thought then it becomes
academic, then some poor slob works out a practical way to implement all that
theory, this is called Engineering - for most people another form of magic.
ok gotcha - i'm writing my buffer now - thanks dennis
Dennis Frost wrote:
At 07:57 PM 3/2/97 +0000, you wrote:
> ORG 20h
> CTR DS 1
> ORG 21h
> CTR2 DS 1
You don't need to put all those ORGs there, as the assembler tracks what
Simply do this:
CTR ds 1
CTR2 ds 1
Then you can insert CTR1 between them:
CTR ds 1
CTR1 ds 3
CTR2 ds 1
and it will know that CTR1 is 3 bytes long, moving CTR2 down.
To access the three bytes of CTR1, you can do the following
Which is the same as multiplying CTR1 = CTR1 * 2.
To access it using FSR is correct, as detailed in another reply.
Andy Kunz - Montana Design - 409 S 6th St - Phillipsburg, NJ 08865
Hardware & Software for Industry & R/C Hobbies
"Go fast, turn right, and keep the wet side down!"
thanks Andy - this is getting to be fun!
Andy Kunz wrote:
Could someone please tell me what this means:
Warn: EDBPIC.ASM 1015:(102) code crosses boundary at 800h
Warn: EDBPIC.ASM 1997:(102) code crosses boundary at 1000h
Warn: EDBPIC.ASM 2881:(102) code crosses boundary at 1800h
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads
Byron A Jeff
On Wed, Jun 11, 2003 at 07:25:53PM -0400, Sid Weaver wrote:
> Could someone please tell me what this means:
> Warn: EDBPIC.ASM 1015:(102) code crosses boundary at 800h
> Warn: EDBPIC.ASM 1997:(102) code crosses boundary at 1000h
> Warn: EDBPIC.ASM 2881:(102) code crosses boundary at 1800h
Just information for you. These are page boundaries and therefore could be
potentially affected by the value in the PCLATH register.
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics
More... (looser matching)
- Last day of these posts
- In 2003
, 2004 only
- New search...