Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

is a > b ? how?

Status
Not open for further replies.

Bear

New Member
Hi,

i am new to pics and programming altogether, but learning.

Can anyone tell me how to test if, for example, W>a_file. ?

I just want to test this and if true, jump out of the loop.

Thanks,

Bear
 
Code:
    SUBWF  MyFile, W     ;subtract W from the file
    BTFSS  STATUS, C     ;Test for borrow (NOT carry)
    GOTO   WBigger       ;W was bigger then file
    ;W was smaller or equal to file

This sample subtracts W from the content of MyFile. If W is bigger then MyFile then there will be an underflow of MyFile and the borrow flag will be set. On a pic borrow is opposite of carry (so carry is clear on borrow and set on no borrow).
We test for the flag and jump accordingly
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top