SX48 Dividing and Bank Handling
Yendor
Posts: 288
I'm still converting code from sx28 to sx48, and looking for some tips with the following:
I have a word variable in bank $60 called TickTimer
Im passing a byte·into the sub and have aligned the value to be in the same bank ($60)
Sub Setit
·tmptimerB1 = __PARAM1
···\ BANK Timing
··TickTimer =·12590 / tmpTimerB1
····TickTimer = TickTimer + tmpTimerW1
··\ BANK $00
ENDSUB
First of all, I'm finding that I need to add ASM bank statements in order for it to start right.
Secondly, when running through SXSim, the banks are not updatating to bank $60 to do the calculation correctly when accessing the TickTimer_LSB and _MSB bytes.
Do I need to go to assembly and add the necessary bank statments for it to work correctly? Note Bold code updates at BANK $00, and not BANK $60 where the variables are located.
Thanks again!
·
I have a word variable in bank $60 called TickTimer
Im passing a byte·into the sub and have aligned the value to be in the same bank ($60)
Sub Setit
·tmptimerB1 = __PARAM1
···\ BANK Timing
··TickTimer =·12590 / tmpTimerB1
····TickTimer = TickTimer + tmpTimerW1
··\ BANK $00
ENDSUB
First of all, I'm finding that I need to add ASM bank statements in order for it to start right.
Secondly, when running through SXSim, the banks are not updatating to bank $60 to do the calculation correctly when accessing the TickTimer_LSB and _MSB bytes.
Do I need to go to assembly and add the necessary bank statments for it to work correctly? Note Bold code updates at BANK $00, and not BANK $60 where the variables are located.
Thanks again!
MOV __PARAM1,#12590& 255 ; tmpTimerW1 = 12590 / tmpTimerB1 MOV __PARAM2,#12590 >> 8 MOV FSR,#tmpTimerB1 MOV __PARAM3,IND CLR __PARAM4 CLR FSR [b]CLR tmpTimerW1_LSB CLR tmpTimerW1_MSB[/b] MOV W,__PARAM3 OR W,__PARAM4 JZ @$+41 CLR __PARAM5 JMP @$+5 CLC RL __PARAM3 RL __PARAM4 INC __PARAM5 JNB __PARAM4.7,@$-4 JMP @$+7 CLC [b]RL tmpTimerW1_LSB RL tmpTimerW1_MSB[/b]
·
Comments
On the SX28, it doesn't matter, as it doesn't have the upper 8 banks of RAM.
Generally, if doing assembly, it helps to use a macro for BANK, e.g.
I generally *always* use the macro for all assembly so it doesn't matter if it compiles for an SX28 or SX48.
Note that on the SX48 it will always take TWO instructions to properly set the bank.
The "BANK" instruction in SX/B handles this for you, so you may not ever have seen it, unless you check the assembly output carefully.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
I knew it had to do with the extra fsr bits and new I had to do a 'bank' - that's killed me enough - but I guess naive (still!) in thinking SX/B handles most of it for us (esp. wiithin a divide function), and didn't think I'd have to convert to assembly.
Just wasn't sure if it was 'the way' or not.
Much appreciated!
HOWEVER, in your code snippet, the BANK statements were "assembly":
BANK someVar ' SX/B
\BANK someVar ' assembly because of the backslash
The first will set all FSR bits properly on an SX48, the second will NOT.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
If I do:
TickTimer = 12590 / tmpTimerB1
by itself, In sx/b, it fails miserably because it updates the wrong registers.
I put the ASM bank statements in there because I was getting an error, and to try to force it in the appropriate bank.
I even had this
INC I
in sx/b and i had to put a bank statement in manually before it to get it to increment.
Let me skeletonize some code tonight to illustrate the point. It's probably just me as usual.
Thanks so much!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
I really appreciate you + the others still frequenting the sx forums!
I will still post some code tonight (prob late - so don't wait up[noparse]:o[/noparse]) ), and would apreciate any advice and pointers.
Thanks!
This is covered in the SX/B docs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php