18C instruction??

Discussion in 'Programmer's Corner' started by MaxHeadRoom, May 31, 2016.

  1. MaxHeadRoom

    Thread Starter Expert

    Jul 18, 2013
    10,509
    2,369
    I am in the process of converting some math routines that were supposedly written for 18C but I cannot find a description in the general 18C Picmicro manual.
    The instruction is 'subwfc' I am assuming it is subtract wreg from file with carry?
    Also what would be the = for 18f series?
    Anyone know for sure.
    Max.
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,136
    1,786
    It might be a macro defined in the particular assembler/compiler used on the original library. This often happens in math libraries, because remembering how subtract with carry works, can be a mind bender.

    Good Luck on your search for an answer.
     
  3. MaxHeadRoom

    Thread Starter Expert

    Jul 18, 2013
    10,509
    2,369
    Thanks, I suspect it is not a macro, this was the comment in the orig file: subwfc x_hi, w ; only works on 18cxxx chips !
    I have found SUBDCF etc and equivalent.
    Max.
     
  4. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    5,675
    899
    Given that syntax and some other evidence it is identical to the current subwfb
    1) With the early chips the pseudo code skpnc and skpc were used in the same way with 18C chips as they are used today (old PicList)
    2) Here is an exampleof how subwfb is worked:
    Code (ASM):
    1.  
    2. ;T1-T2  when T1 = T2, Status,C is set
    3. ;works   T2 is preserved
    4.      movf      T2L,w     ;
    5.      subwf     T1L,f     ;
    6.      movf      T2H,w     ;
    7.      subwfb    T1H,f     ;
    8.      nop
    9.  
    Since it is the last step is 16-bit math, whether you save in w or f is up to you.

    John
     
  5. MaxHeadRoom

    Thread Starter Expert

    Jul 18, 2013
    10,509
    2,369
    Thanks, I guess I didn't look hard enough, (18f Instruction set).
    Max.
     
Loading...