Decrementing unsigned int with PIC18F assembly language?

Discussion in 'Embedded Systems and Microcontrollers' started by spinnaker, Jan 24, 2011.

  1. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015
    Say I have an unsigned in defined in C.

    Code ( (Unknown Language)):
    1.  
    2.  
    3. unsigned int;
    4.  
    5. _asm  
    6.  
    7.  
    8. _endasm
    9.  
    10.  
    11.  
    How do I decrement it in PIC18F assembler? I know I can use DCFSNZ to decrement a file register but that is only 8 bit correct? Do I need to move the lo and hi bytes into 2, 8 bit registers?
     
  2. JDT

    Well-Known Member

    Feb 12, 2009
    658
    85
    I don't know the 18F assembler commands but basically for a two byte decrement:-

    Test the low byte for zero.
    If it is zero, decrement the high byte, otherwise skip.
    Decrement the low byte.
     
  3. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015
    I was hoping there was an easier way. :)
     
Loading...