how to add two binary inputs?

Status
Not open for further replies.

aerial

New Member
need some ideas on how i can add two binary inputs using the P16F84A rb port as an input of the two binary ....interrupt is enable using rbo...rb1, rb2, rb3 are inputs for the first binary while rb4,rb5,rb6 and rb7 for the input of the second binary...the result of the sum will be shown using porta (rbo-rb3) as the output..each time an interrupt occurs the result of the addition will be displayed...thanks.
 
Check the PIC instruction set! - CLUE: look for instructions that begin 'ADD'.

Or ask your teacher! - this is yet another obvious school question!.
 
Use your imagination and creativity

Make a flow chart of the steps you think you'll need
Something like:
1) read port b
2) keep only the lowest 4 inputs using a .... instuction with constant ????
4) store the result in 'Operand_A'
5) read port b
6) keep only the highst 4 inputs using a .... instuction with constant ????
7) divide by y so that the input comes in the LSB
8) store the result in 'Operand_B'
9) Add 'Operand_A' to 'Operand_B'

Give us some proposition for the ...., ????, y, remove unnecessary steps, add the ones I forgot, ...

Writing code is for 95% imagination and creativity, obviously you don't have it yet.

Good luck
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…