PIC opcode decoder question

Discussion in 'Embedded Systems and Microcontrollers' started by Hrvach, Oct 14, 2014.

  1. Hrvach

    Thread Starter New Member

    Oct 14, 2014
    2
    0
    Hi everybody, I'm new here.

    I'm trying to figure out something regarding opcodes in PIC 10F200 (datasheet http://ww1.microchip.com/downloads/en/DeviceDoc/41239D.pdf).

    Page 46, list of opcodes - TRIS is 0000 0000 0fff where fff is the operand (000 - 111). OPTION is 0000 0000 0010. How can the instruction decoder differentiate between tris where operand is 010 and OPTION instruction?

    Any clarification on this would be greatly appreciated. Thanks!
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,791
    The operand of the TRIS instruction is decoded as the address of a file register that controls the status of output port bits. The operand b'010' does not refer to an actual TRIS register or corresponding output port and so this value can be used for another purpose. If you look at the description of the instruction f=b'110' is the only valid value. I know the description mentions f=b'111' but I think that is a cut and paste typo.
     
  3. Hrvach

    Thread Starter New Member

    Oct 14, 2014
    2
    0
    Thanks, now it makes much more sense. I thought they were all allowed and I was missing some clever feature instruction decoder uses to decide which instruction to execute.
     
  4. Papabravo

    Expert

    Feb 24, 2006
    10,144
    1,791
    Even on the mid-range PIC processors the TRIS registers are normally assigned to addresses ending 5,6, and 7. In many cases for mid-range PIC processors the TRIS instruction is deprecated, but is maintained in the instruction set for compatibility. It originally referred to a register that did not have a defined address in the register file. See PIC16C54 for this implementation. See PIC 15F628A for the more modern implementation.

    Good catch, by the way.
     
Loading...