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.

Assembly Language on PIC 16F872 on Subtraction

Status
Not open for further replies.

scdoro

Member level 5
Member level 5
Joined
Jan 12, 2005
Messages
87
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,040
assembly language subtraction pic

Hi,
I am new to assembly language. I need to write a routine to compare VALUE1 with VALUE2, if VALUE1 is better than VALUE2, will skip the next statement.
I am using PIC 16 F872 thus there is this no compare instruction set.
If i use the substraction instruction, i need to take care of the complement value too ....
May I know how to write the routine ?

eg, if i want to subtract 99 from 44, sure there will be a negative, how do i takecare of that using complement method.
or is there any other alternative ?
Is there any sample which i can make references to ?
thanks..
 

You can use SUBLW instruction and read bits C(which also acts as borrow) and Z.
If A>B after A-B the C bit will be unaffected,
If A<B after A-B the C bit will affected
If A=B after A-B the Z bit will be affected ..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top