On Fri, 6 Nov 1998 13:38:21 -0500 myke predko writes: >Recently, I put up a 16 bit multiplication algorithm on my web page >along >with a 32 bit result. Oyvind Kaurstad has pointed out to me that the >addition routine that is on the web page does not pass the correct >carry >value the case: > > 0x0FF >+0x001 > >when the Carry Flag is already set. The correct result is of course 1 with the carry set. The classic method for adding 8 bits with carry works in every case: movfw A skpnc incfsz A,w addwf B,f Anytime the C is set going in, the incfsz executes, replacing the value loaded into W by the first instruction with A+1. If A is FF, the add is skipped, since it would clear the carry out by adding zero. So if A = FF, B = 1, and C = 1, the result left in B is unchanged (1) and the carry flag is unchanged (1). If A= 1, B = FF, and C = 1, then the incfsz moves A + 1 (which is 2) into W and doesn't skip. The add executes adding FF and 2 which is 1 with a carry of 1. Again the result is correct. In order to add larger numbers with carry just repeat this routine for each byte in the number starting with the LSB. ___________________________________________________________________ You don't need to buy Internet access to use free Internet e-mail. Get completely free e-mail from Juno at http://www.juno.com/getjuno.html or call Juno at (800) 654-JUNO [654-5866]