ON 20010302@11:34:38 AM at page: http://www.piclist.com/techref/scenix/lib/math/radix/b2bp-32b10d_sx.htm JMN-EFP-786 James Newton edited the page ON 20010302@11:38:40 AM at page: http://www.piclist.com/techref/scenix/lib/math/radix/b2bp-32b10d_sx.htm JMN-EFP-786 James Newton added 'Code: b2bcd3 mov W, #$33 add indf, W ; add to both nybbles snb indf.3 ; test if low result > 7 and W, #$f0 ; low result >7 so take the 3 out snb indf.7 ; test if high result > 7 and W, #$0f ; high result > 7 so ok sub indf, W ; any results <= 7, subtract back inc fsr ; point to next decsz cnt jmp b2bcd3 rl bin+3 ; get another bit rl bin+2 rl bin+1 rl bin+0 rl bcd+4 ; put it into bcd rl bcd+3 rl bcd+2 rl bcd+1 rl bcd+0 decsz ii ; all done? jmp b2bcd2 ; no, loop ret ; yes end ' ON 20010302@11:39:04 AM at page: http://www.piclist.com/techref/scenix/lib/math/radix/b2bp-32b10d_sx.htm JMN-EFP-786 James Newton edited the page ON 20010302@11:39:20 AM at page: http://www.piclist.com/techref/scenix/lib/math/radix/b2bp-32b10d_sx.htm JMN-EFP-786 James Newton added 'Code: http://www.usbmicro.com b2bcd3 mov W, #$33 add indf, W ; add to both nybbles snb indf.3 ; test if low result > 7 and W, #$f0 ; low result >7 so take the 3 out snb indf.7 ; test if high result > 7 and W, #$0f ; high result > 7 so ok sub indf, W ; any results <= 7, subtract back inc fsr ; point to next decsz cnt jmp b2bcd3 rl bin+3 ; get another bit rl bin+2 rl bin+1 rl bin+0 rl bcd+4 ; put it into bcd rl bcd+3 rl bcd+2 rl bcd+1 rl bcd+0 decsz ii ; all done? jmp b2bcd2 ; no, loop ret ; yes end ' ON 20010302@11:39:56 AM at page: http://www.piclist.com/techref/scenix/lib/math/radix/b2bp-32b10d_sx.htm JMN-EFP-786 James Newton edited the page ON 20010302@11:41:00 AM at page: http://www.piclist.com/techref/scenix/lib/math/radix/b2bp-32b10d_sx.htm JMN-EFP-786 James Newton added 'Code: http://www.usbmicro.com ;****************************************************************** ; Convert 32-bit binary number at into a bcd number ; at . Uses Mike Keitz's procedure for handling bcd ; adjust; Modified Microchip AN526 for 32-bits. b2bcd mov W, #32 ; 32-bits mov ii, W ; make cycle counter clr bcd ; clear result area clr bcd+1 clr bcd+2 clr bcd+3 clr bcd+4 b2bcd2 mov W, #bcd ; make pointer mov fsr, W mov W, #5 mov cnt, W ; Mike's routine: b2bcd3 mov W, #$33 add indf, W ; add to both nybbles snb indf.3 ; test if low result > 7 and W, #$f0 ; low result >7 so take the 3 out snb indf.7 ; test if high result > 7 and W, #$0f ; high result > 7 so ok sub indf, W ; any results <= 7, subtract back inc fsr ; point to next decsz cnt jmp b2bcd3 rl bin+3 ; get another bit rl bin+2 rl bin+1 rl bin+0 rl bcd+4 ; put it into bcd rl bcd+3 rl bcd+2 rl bcd+1 rl bcd+0 decsz ii ; all done? jmp b2bcd2 ; no, loop ret ; yes end ' ON 20010302@11:41:39 AM at page: http://www.piclist.com/techref/scenix/lib/math/radix/b2bp-32b10d_sx.htm JMN-EFP-786 James Newton edited the page