Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

MPASM, PIC18F65K22: Check if one number is greater than another?

Status
Not open for further replies.
T

treez

Guest
Newbie level 1
Hello,
I am coding in MPASM (microchip) for PIC18F65K22.

I have numbers contained in two registers,
One is called ana8, the other is called max_led_temp.

I wish to find out if the value in ana8 is greater than the value in max_led_temp.
Can I do this by subtracting ana8 from max_led_temp and checking if the Carry flag of the status register is set?…eg


Code ASM - [expand]
1
2
3
4
5
movf    ana8,w
bcf     STATUS,C
subwf   max_led_temp,w
btfsc   STATUS,C
goto    overtemp



(the numbers in either register may be between 0 and 255)
 
Last edited by a moderator:

yes, that is the way to do it.
There is another possible outcome you might also want to check, that the two values are equal. The Z flag will tell you that.

Brian.
 
  • Like
Reactions: treez

    T

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top