Exact match. Not showing close matches.
PICList
Thread
'[SX] Using IND as register -- works with all instr'
2008\08\10@185450
by
Zootn/a
|
|
I'm modifying this project -- So.... I have a number of cases where my code space is much much tighter presuming that I can use IND whereever I would use a normal register (presuming FSR is set correctly ahead of time). E.g. ---------- End of Message ----------
MOV W, #registers
ADD W, globalIndex
MOV FSR, W
CJA IND, globalB1, @:decit
CJB IND, globalB1, @:incit
JMP @:done
:decit
DEC IND
SKIP
:incit
INC IND
:done
Presuming this will work? Most of the code I see with IND tends to be CLRs and MOVs, etc.
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=284586
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)
|
|
Zoot,
As long as FSR doesn't change, yes you can use IND as a global byte variable.
Bean.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=284586#m284659
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)
|
|
Cool. I'm actually getting a real handle on FSR manipulation. Get me much more compact code.
Quasi related question re: FSR and IND.
The BANK instruction (ASM) sets only the upper 3 bits (SX28) or upper 4 bits (SX48) and *leaves the lower 4 bits alone*. Is that right? If so then I can really compact my code because I have a number of routines where the app needs to access the same indexed registers from more than one bank (in this case, say, I have servo ramp values, positions, accumulators, stored in 4 banks). In the past I've set bits manually on the FSR to jump back and forth and realized there has to be a better way :-)
I.E., would this work?
' say pos is BANK 1, ramp is BANK 2, acc is BANK 3
' I want to access the 3rd reg in B1, 3rd reg in B2, etc
MOV globalIndex, #3
MOV W, #pos
ADD W, globalIndex
MOV FSR, W ' FSR = $33
MOV IND, globalB1
BANK #ramp ' FSR = $53
MOV globalB1, IND
BANK #acc ' FSR = $73
MOV IND, globalB1
MOV W, globalIndex
MOV FSR, W ' FSR = $x3
BANK #ramp ' FSR = $53
MOV globalB1, IND
BANK #acc ' FSR = $73
MOV IND, globalB1
2008\08\11@084458 by peterverkaikn/a
|
|
Zoot,
The banked memory allows for even better optimization for multiple identical code,
for example receive uarts, because not only can you use IND but also direct addressing.
See the attached file which is a header for a uart library that I am writing.
Note the uart fields as being declared in the ram area $10-$1F.
The code is written as a macro and will only be inserted once in the program.
But this code can be called with FSR set to any bank, eg. $30, $40 or $E0 etc.
The direct addressed registers are actual at the offsets in the bank addressed by FSR.
So this code can support multiple receive uarts without writing code for each of
those uarts seperately. All that needs to be done is to set some registers and this can be done
from a datatable (that 's how I do it in my library).
regards peter
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=284586#m284680
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)
|
|
Peter -- sure. I get it! What an epiphany. Makes me want to go back and recode all my older (inefficient) projects :-)
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=284586#m284692
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)
More... (looser matching)
- Last day of these posts
- In 2008
, 2009 only
- Today
- New search...