Searching \ for 'compare/if/then' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: massmind.org/techref/index.htm?key=compareifthen
Search entire site for: 'compare/if/then'.

Truncated match.
PICList Thread
'compare/if/then'
1996\11\19@085517 by Clewer,Brian

flavicon
face
Hi, does anyone have any macros for 'IF THEN' statements and also a compare
function.

Thanks in advance,
    Brian.

1996\11\20@170159 by siegfried.grob

flavicon
face
Brian wrote

> Hi, does anyone have any macros for 'IF THEN' statements and also a compare
> function.
>


I have written a collection of macros for often needed
IF A < > <= >= == B THEN GOTO ...
constructions.

How to use:
1. Load the W-reg with value 'A'
2. Choose the right Compare-and-Branch macro

An example:
MOVLW  d'10'
CFWBG  B,LABEL    ; compare fileregister B with W-register,
                 ; branch to LABEL if fileregister is greater than w-register


Attention!
I have not tested all macros
under all combinations of data values. So, think twice about any
macro before you use it! Any helpful comments are welcome.
Some macros will not work on 16C5x because of the SUBLW command.

Here they are:

          nolist

;       sublw    l      ; w := l - w
;
;       C  Z  result
;       --------------
;       0  0  l < w
;       0  1  illegal
;       1  0  l > w
;       1  1  l = w
;
;       Carry only:
;       1  .  l >= w
;       0  .  l < w


CLWBG      macro   lit, addr       ; Compare Literal to Work, Branch if Greater
          local   theend          ; if lit > W then GOTO addr
          SUBLW   lit
          bz      theend
          bc      addr
theend
          endm


CLWBGE     macro   lit, addr       ; Compare Literal to Work, Branch if Greater
or Equal
                                  ; if lit >= W then GOTO addr
          SUBLW   lit
          bc      addr
          endm


CLWBL      macro   lit, addr       ; Compare Literal to Work, Branch if Less
                                  ; if lit < W then GOTO addr
          SUBLW   lit
          bnc     addr
          endm


CLWBLE     macro   lit, addr       ; Compare Literal to Work, Branch if Less or
Equal
                                  ; if lit <= W then GOTO addr
          SUBLW   lit
          bz      addr
          bnc     addr
          endm


CLWBE      macro   lit, addr       ; Compare Literal to Work, Branch if Equal
                                  ; if lit == W then GOTO addr
          SUBLW   lit
          bz      addr
          endm


CLWBNE     macro   lit, addr       ; Compare Literal to Work, Branch if Not
Equal
                                  ; if lit != W then GOTO addr
          SUBLW   lit
          bnz     addr
          endm


CFWBG      macro   file, addr      ; Compare File to Work, Branch if Greater
          local   theend          ; if file > W then GOTO addr
          SUBWF   file,W
          bz      theend
          bc      addr
theend
          endm


CFWBGE     macro   file, addr      ; Compare File to Work, Branch if Greater or
Equal
                                  ; if file >= W then GOTO addr
          SUBWF   file,W
          bc      addr
          endm


CFWBL      macro   file, addr      ; Compare File to Work, Branch if Less
                                  ; if file < W then GOTO addr
          SUBWF   file,W
          bnc     addr
          endm


CFWBLE     macro   file, addr      ; Compare File to Work, Branch if Less or
Equal
                                  ; if file <= W then GOTO addr
          SUBWF   file,W
          bz      addr
          bnc     addr
          endm


CFWBE      macro   file, addr      ; Compare File to Work, Branch if Equal
                                  ; if file == W then GOTO addr
          SUBWF   file,W
          bz      addr
          endm


CFWBNE     macro   file, addr      ; Compare File to Work, Branch if Not Equal
                                  ; if file != W then GOTO addr
          SUBWF   file,W
          bnz     addr
          endm


          list



Siegfried Grob                                              |
student of electrical engineering at the University of Ulm  |
e-mail: spam_OUTsiegfried.grobTakeThisOuTspamstudent.uni-ulm.de                   |
phone&fax: +49-7304-921372                                  |
------------------------------------------------------------'

1996\11\21@115904 by Giles L. Honeycutt

flavicon
face
Clewer,Brian wrote:
>
> Hi, does anyone have any macros for 'IF THEN' statements and also a compare
> function.
>
> Thanks in advance,
>      Brian.

I have some nice macros that are short ans sweet, I will post them when I get
to work.  As I am at home not.. I should be today.  Not exactly what you are
asking for, but I think you will like them.

            Giles L. Honeycutt

1996\11\22@084343 by D. R. Chicotel

flavicon
face
At 01:53 PM 11/19/96 PST, you wrote:
>Hi, does anyone have any macros for 'IF THEN' statements and also a compare
>function.
>
>Thanks in advance,
>     Brian.
>
>

Try including this in your source:


; -------------------------------------------------------------------------
; COMPARE.INC
;
; Macros to compare and branch/skip/call
;
; -------------------------------------------------------------------------
; Usage                                  Description
; ----------------------------------     ----------------------------------
; clskpe     label1, label2              Compare literal and skip if equal
; clskpne    label1, label2              Compare literal and skip if not equal
; clje       label1, label2, address     Compare literal and jump to if equal
; cljne      label1, label2, address     Compare literal and jump to if not
equal
; clcalle    label1, label2, address     Compare literal and call if equal
; clcallne   label1, label2, address     Compare literal and call if not equal
; cskpe      label1, label2              Compare and skip if equal
; cskpne     label1, label2              Compare and skip if not equal
; cje        label1, label2, address     Compare and jump to if equal
; cjne       label1, label2, address     Compare and jump to if not equal
; ccalle     label1, label2, address     Compare and call if equal
; ccallne    label1, label2, address     Compare and call if not equal
;
; -------------------------------------------------------------------------

clskpe   MACRO   label1, label2               ; compare literal and skip if
equal
        movlw   label2                       ; (macro)
        xorwf   label1, 0                    ; (macro)
        btfss   3, 2                         ; (macro)
        ENDM

clskpne  MACRO   label1, label2               ; compare literal and skip if
not equal
        movlw   label2                       ; (macro)
        xorwf   label1, 0                    ; (macro)
        btfsc   3, 2                         ; (macro)
        ENDM

clje     MACRO   label1, label2, address      ; compare literal and jump to
if equal
        movlw   label2                       ; (macro)
        xorwf   label1, 0                    ; (macro)
        btfsc   3, 2                         ; (macro)
        goto    address                      ; (macro)
        ENDM

cljne    MACRO   label1, label2, address      ; compare literal and jump to
if not equal
        movlw   label2                       ; (macro)
        xorwf   label1, 0                    ; (macro)
        btfss   3, 2                         ; (macro)
        goto    address                      ; (macro)
        ENDM

clcalle  MACRO   label1, label2, address      ; compare literal and call if
equal
        movlw   label2                       ; (macro)
        xorwf   label1, 0                    ; (macro)
        btfsc   3, 2                         ; (macro)
        call    address                      ; (macro)
        ENDM

clcallne MACRO   label1, label2, address      ; compare literal and call if
not equal
        movlw   label2                       ; (macro)
        xorwf   label1, 0                    ; (macro)
        btfss   3, 2                         ; (macro)
        call    address                      ; (macro)
        ENDM

cskpe    MACRO   label1, label2               ; compare and skip if equal
        movf    label2, 0                    ; (macro)
        xorwf   label1, 0                    ; (macro)
        btfss   3, 2                         ; (macro)
        ENDM

cskpne   MACRO   label1, label2               ; compare and skip if not equal
        movf    label2, 0                    ; (macro)
        xorwf   label1, 0                    ; (macro)
        btfsc   3, 2                         ; (macro)
        ENDM

cje      MACRO   label1, label2, address      ; compare and jump to if equal

        movf    label2, 0                    ; (macro)
        xorwf   label1, 0                    ; (macro)
        btfsc   3, 2                         ; (macro)
        goto    address                      ; (macro)
        ENDM

cjne     MACRO   label1, label2, address      ; compare and jump to if not equal
        movf    label2, 0                    ; (macro)
        xorwf   label1, 0                    ; (macro)
        btfss   3, 2                         ; (macro)
        goto    address                      ; (macro)
        ENDM

ccalle   MACRO   label1, label2, address      ; compare and call if equal

        movf    label2, 0                    ; (macro)
        xorwf   label1, 0                    ; (macro)
        btfsc   3, 2                         ; (macro)
        call    address                      ; (macro)
        ENDM

ccallne  MACRO   label1, label2, address      ; compare and call if not equal
        movf    label2, 0                    ; (macro)
        xorwf   label1, 0                    ; (macro)
        btfss   3, 2                         ; (macro)
        call    address                      ; (macro)
        ENDM

1996\11\22@115441 by Joe Dowlen
flavicon
face
    Check out http://hobbes.king.ac.uk/matt/pic/logic.html for some neat
    compare functions.

    Joe


______________________________ Reply Separator _________________________________
Subject: compare/if/then
Author:  pic microcontroller discussion list <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU> at SMTP
Date:    11/22/96 2:54 AM


Hi, does anyone have any macros for 'IF THEN' statements and also a compare
function.

Thanks in advance,
    Brian.


'compare/if/then'
1996\12\01@075651 by hoss karoly
flavicon
face
> Hi, does anyone have any macros for 'IF THEN' statements and also a compare
> function.
>

I'd check out the parallax assembly macros they are great
and simple

bye
charley

More... (looser matching)
- Last day of these posts
- In 1996 , 1997 only
- Today
- New search...