Surprisingly Useless PIC18F Discovery

Discussion in 'Embedded Systems and Microcontrollers' started by joeyd999, Sep 17, 2013.

  1. joeyd999

    Thread Starter AAC Fanatic!

    Jun 6, 2011
    Having used the 18F series Microchips for many years, I thought I knew everything about them...

    Perusing the 18F85J90 family datasheet last night, I saw something I'd never noticed before: The CALL and RETURN instructions have an extra argument 's'.

    According to the datasheet, if the 's' argument is 1, then WREG, STATUS, and BSR are pushed onto the "fast return stack" for a CALL and popped off the stack for a RETURN.

    Neat, I thought...I could find some use for this.

    But, playing around, I realized that the "fast return stack" in question is the same fast return stack that is used for interrupts, regardless if RETFIE FAST instruction is used or not.

    So, basically, the stack gets corrupted if an interrupt is triggered in the middle of a subroutine that uses it. I suppose one could disable interrupts prior to making the call and re-enabling them after the return. But that doesn't make much sense.

    So, this CALL/RETURN option seems to be useless -- and dangerous for the uninitiated -- yet no cautionary statement is made in the entire datasheet. It's a wonder they included it in the instruction set.

    Just thought I'd bring this up for those who might be interested.
    ErnieM and MrChips like this.
  2. MrChips


    Oct 2, 2009
    Thanks for this.
    I will chalk that one as another idiosyncratic reason not to use PICs.
  3. joeyd999

    Thread Starter AAC Fanatic!

    Jun 6, 2011
    That leaves more PICs for me!
  4. #12


    Nov 30, 2010