Shop OBEX P1 Docs P2 Docs Learn Events
Shadow Registers ?? — Parallax Forums

Shadow Registers ??

DWinchellDWinchell Posts: 60
edited 2004-12-20 16:50 in General Discussion
I am intrested in doing some real time premptive Multi-Tasking using the RTCC and the four pages inthe SX chip. Is there any to see what's in the stack to get and /or change the Program counter ?? The SX docs indicate that the running task is pushed into "Shadow Registers" when servicing interrupts. I can't find any way to look at the stack or these shadow registers.·Are the 8·stack registers memory mapped to accessable bank registers ??

6.1.2 Subroutine Stack
The subroutine stack consists of eight 11-bit save registers.
A physical transfer of register contents from the program
counter to the stack or vice versa, and within the
stack, occurs on all operations affecting the stack, primarily
calls and returns. The stack is physically and logically
separate from data RAM. The program cannot read or
write the stack.

Upon return from the interrupt service routine, the contents
of PC, FSR, STATUS, and W registers are restored
from their corresponding shadow registers. The interrupt
service routine should end with instructions such as RETI
and RETIW. RETI pops the interrupt stack and the special
shadow registers used for storing W, STATUS, and
FSR (preserved during interrupt handling). RETIW
behaves like RETI but also adds W to RTC.


Is there another approach to Multi-Tasking ??

Comments

  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2004-10-18 07:08
    Hello DWinchell,

    the stack memory and the shadow registers are not memory mapped, i.e. you cannot directly read from or write to these registers. The handling of pushing the current PC on the stack, and saving the most important registers to the shadow registers on an interrupt, and restoring these registers on a RETI, or RETIW instruction is fully transparent to the application.

    Using shadow registers was a clever idea of the SX designers because this makes it unnecessary to "manually" save these registers at the entry point of the ISR, and restoring them before a return from an interrupt like it is required with other controllers.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,


    G
  • StephenStephen Posts: 53
    edited 2004-10-18 15:53
    I can see how some of the debug instructions (for FIFO and/or the PUSH/POP to SFR functions) would be useful for an RTOS. You would have to get the debug spec to see how they are used. Using them of course would not allow you to debug your code any more...

    Post Edited (Stephen) : 10/18/2004 6:22:38 PM GMT
  • DWinchellDWinchell Posts: 60
    edited 2004-10-19 06:04
    Does anyone no of a source for the Debug instructions ?? What does BREAK do ?? Whats the OPcode ?? ...
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2004-10-19 12:25
    BREAK is not an SX instruction, and therefore, does not have a corresponding op-code. It is a directive for the SX-Key to automatically insert a breakpoint for the debugger.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,


    G
  • DWinchellDWinchell Posts: 60
    edited 2004-10-19 17:08
    How does the Debugger work ?? Any documentation ?? How does the BREAK directive work ??
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2004-10-26 03:52
    As it happened, today I came across this page:

    http://users.senet.com.au/~akouz/main.html

    It shows a program pic_rrr (round robin rtos for pic16)

    If you download the package and read the files

    readme.txt and pic_rrr.asm and macro.asm

    you see how it is done for the pic. Macro's !

    This should be portable to sx without too much effort.

    Not quite pre-emptive, but you can return control to the kernel

    to mimic·pre-emptive behaviour. (eg. all tasks run predefined time slices)

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2004-10-26 10:57
    Here is an article on rtos that uses 16C54 and 16C64, with detailed

    explanations and source code.

    http://www.eetkorea.com/ARTICLES/2000JUN/2000JUN06_CT_AN3.PDF

    regards peter
  • James NewtonJames Newton Posts: 329
    edited 2004-10-26 17:37
    Use

    http://www.sxlist.com/cgi-bin/mpasm2sasm2.exe

    to convert from MPASM to SASM

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ---
    James Newton, Host of SXList.com
    james@sxlist.com 1-619-652-0593 fax:1-208-279-8767
    SX FAQ / Code / Tutorials / Documentation:
    http://www.sxlist.com Pick faster!



  • DWinchellDWinchell Posts: 60
    edited 2004-10-27 01:32
    Thank You ALL smile.gif
  • Paul BakerPaul Baker Posts: 6,351
    edited 2004-12-15 16:38
    This thread is actually quite humourous in context to the secret instructions now disclosed, I'd thought id bump it in hopes in DWinchell (if hes still cruising here) noticing these things are now attainable.
  • James NewtonJames Newton Posts: 329
    edited 2004-12-15 22:22
    I also hope we can stimulate some more postings of code or findings related to the new instructions... Come on guys! Don't let me have the last word on it... my little call and return example can't be the last word.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ---
    James Newton, Host of SXList.com
    james@sxlist.com 1-619-652-0593 fax:1-208-279-8767
    SX FAQ / Code / Tutorials / Documentation:
    http://www.sxlist.com Pick faster!



  • DWinchellDWinchell Posts: 60
    edited 2004-12-19 01:40
    WOW NEW INSTRUCTIONS !! And just when I desided that SX/Basic was filling all my needs :-) Time to start reading assembler again.

    I did run across something interesting when I put to much code in the last Code page ( $600-$7FF ) The error message reads: "THE LAST 136 BYTES ARE RESURVED FOR THE DEBUGGER" Not sure if 136 was the real number or not. I was actually to busy to think about this until latter. Now let's see if we extracted the code in this space, disassembled it, I bet we would have a debugger :-) Let's see I bet the break point jumps to this address :-) AND THE BEAT GOES ON :-) This machine just seems to get better all the time :-)

    Thank You

    David Winchell
  • PJMontyPJMonty Posts: 983
    edited 2004-12-19 07:32
    David,

    Personally, I don't know if the new instructions (or the old) will let you disassemble the code used to communicate with the SXKey. Chip Gracey is the person who wrote this software originally (and designed the key and wrote the software for it as well), and after having worked with it for a few years now, I am ever more aware of how much work he had to put into it. If you try it, I wish you lots of luck and all the long hours you feel like putting into it. Of course, you could simplify your life and just use the existing software that works right now...
      hanks, PeterM
  • DWinchellDWinchell Posts: 60
    edited 2004-12-19 21:34
    Got LOT's of other pressing tasks just now smile.gif Was only an insight not. I wrote a Monitor/Debugger for a General Automation mini-computer once upon a time. This machinewas a von Neumann type architecture that allowed self modifing code. The Harvard SX machine would be interesting to say the least. It was months worth of work. I think I will just use this one it works real good.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2004-12-20 16:50
    I have an idea that perhaps with the new instructions and taking information on programming an SX, perhaps by leaving some portion of memory unprogrammed, there is some means for in system self programming the unprogrammed area. I suspect some simple state machine in a PAL/GAL/CPLD etc may be nessesary and the applications for this maybe limited to the point of not really being usable (such as storing calibration info or other data which could be more easily stored in off-board nvram) but the potential is interesting.

    Paul
Sign In or Register to comment.