Shop OBEX P1 Docs P2 Docs Learn Events
__remainder — Parallax Forums

__remainder

basicstampedebasicstampede Posts: 214
edited 2008-08-20 19:37 in General Discussion
What is __REMAINDER?

Reading chapter 11 of "Practical SX/B", I come across an undeclared variable called __REMAINDER.

Say,

potVal = 125
digit = potVal / 100
newVal = __REMAINDER

At this point, does newVal equal to 25?

What other hiddent niceties similar to __REMAINDER are there?

Thanks.

Comments

  • BeanBean Posts: 8,129
    edited 2008-08-20 12:46
    Yes, __REMAINDER would be 25.
    There is also __WREMAINDER for division of WORD variables.

    Note that __REMAINDER is stored in temporary RAM space. So it should be assigned immediately after the division operation.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    "A government big enough to give you everything you want, is big enough to take away everything you·have."·· Thomas Jefferson

    "It is our choices, Harry, that show what we truly are, far more than our abilities."·Dumbledore from Harry Potter

    www.iElectronicDesigns.com

    ·
  • basicstampedebasicstampede Posts: 214
    edited 2008-08-20 13:38
    Bean, thanks for your comment.

    What other things such as __REMAINDER are there and where can I learn about them?

    Thanks.
  • JonnyMacJonnyMac Posts: 9,215
    edited 2008-08-20 14:57
    The SX/B help file is full of this kind of information....
  • ZootZoot Posts: 2,227
    edited 2008-08-20 19:37
    Also if you view the list file from any sx/b program you'll see all the assigned registers.

    If memory serves (I don't have docs w/me right now), __REMAINDER is also __PARAMCNT is also __PARAM5, which is why you need to grab it right away if you want it.

    There are also some other *hidden* registers assigned by SX/B that you can use to extend variable space *if you know what you're doing*. For example a number of bytes are assigned at __INTPARAMFSR (five bytes in SX/B 1.51.03 and six bytes in SX/B 2.0) -- these are used for saving and retrieving the M, __PARAM1, __PARAM2, __PARAM3, __PARAM4, and __PARAMCNT registers during interrupts (SX/B 1.51.03 does not preserve __PARAMCNT btw, but SX/B 2.0 will).

    If you have NOPRESERVE set for your ISR, then you free up these bytes. I generally set NOPRESERVE, but use the first __INTPARAMFSR register (by hand) to save/restore the M register (otherwise any TRIS work you do in the ISR will muck up TRIS work in the mainline and vice versa), leaving me some extra bytes to play with.

    e.g., with NOPRESERVE on, I get another 4 bytes in 1.51.03, and I put this at the top of my ISR:

    MOV W, #__INTPARAMFSR+0
    MOV FSR, W
    MOV IND, M
    '...
    'and at the endof the ISR:
    MOV W, #__INTPARAMFSR+0
    MOV FSR, W
    MOV M, IND
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php


    Post Edited (Zoot) : 8/20/2008 7:51:17 PM GMT
Sign In or Register to comment.