MPASM Macro : ckGRT (Compare File Greater Than Constant)

 

 

Introduction

Compares a file register to a constant and determines if the file is greater than a constant. If greater than then jump to the passed address.

 

 

Macro Flowchart

 

 

Macro Code

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
;************************************************************************
; Macro: ckGRT                                            Version: 1.00 *
; Author: Garrett Blanton                                               *
;************************************************************************
; Description: Compare a file register to a constant and determine if   *
;              the file is greater than the constant.  If greater than  *
;              then jump to the passed address.                         *
;************************************************************************
; Parameters: arg1 File register 1                                      *
;             arg2 Constant                                             *
;             addr Jump to address if files equal                       *
;************************************************************************
ckGRT   macro  arg1, arg2, addr   ; Compare File Equal    
        movf   arg1, W            ; WREG = arg1   
        sublw  arg2               ; WREG = WREG - arg2   
        btfss  STATUS, C          ; C = 0?   
        goto   addr               ; GOTO addr   
        endm 

 

Code Example

 

ckGRT Assembly Code Example
(January 28, 2012)
Download: downloadDownload
Summary: cfGRT macro example program. Compares a file register to a constant and determines if the file is greater than a constant. If greater than then jump to the passed address.
Categories: ckGRT

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>