Put the 35 into a register and successively subtract 10 from it and every time through the loop add 1 to another register. Check the status flags for an underflow, and when you get one, add back the latest '10' you subtracted and put the remainder in the third register. See the following run through... w = 35 ; Initial number num equ 0x20 ; Temporary holding place for number tens equ 0x21 ; Holding place for Tens ones equ 0x22 ; Holding place for Ones movwf num ; Put num in holding register movlw 0x0A ; Subtract 10d from num register subwf num,1 ; place result back in temp register btfss 0x03,1 ; Check for underflow goto rmdr ; If underflow, go get the units count movlw 0x01 ; Add one to tens register to count movwf tens ; this time through the loop goto $-6 ; If not, go back and subtract another 10d rmdr: ; Get units count addwf num,0 ; add the last 10d back into the number movwf ones ; 'w' now contains the ones remaining return ; Go back to calling program So we subtract 10 from 35, put the result (25) in num, and check for underflow. No underflow, so we subtract another 10 and put result in num (15), check for underflow. No underflow, so we subtract another 10 and put result in num (5), check for underflow. No underflow, so we subtract another 10 and put result in num (-5), check for underflow. We have underflow this time, so we add the last subtract back into num making it 5 again. And we save this number in the Ones register. So at this point we have 'w' containing 5, num containing 5, Tens containing 3, and ones containing 5 ----- Original Message ----- From: Tim Webb To: Sent: Friday, February 01, 2002 5:37 PM Subject: [PIC]: Binary to Decimal conversion help > I have a number from 0 to 35 and I want to seperate the tens and the ones > into two seperate file registers > How do I do it using a 16F877 ? > > Most of examples that I have found on the piclist are using instructions the > 16f877 does not have. > > -- > http://www.piclist.com hint: To leave the PICList > mailto:piclist-unsubscribe-request@mitvma.mit.edu > > -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu