**************************************************************************** **************************************************************************** ** ** Platinum Edition (BCD number handling) ** ** This software is in the public domain. There is no warranty. ** ** by Patrick Davidson (pad@calc.org, http://pad.calc.org/) ** ** Last updated July 28, 2001 ** **************************************************************************** **************************************************************************** ******************************************* ADD BCD LONGWORDS * * Adds (A0) to (A1), changing A0 and A1. Pointers should initially point * right past the end of the longwords. * ******** Add_BCD: andi #0,ccr abcd -(a0),-(a1) abcd -(a0),-(a1) abcd -(a0),-(a1) abcd -(a0),-(a1) rts ******************************************* SUBTRACT BCD LONGWORDS * * Subtracts (A0) from (A1), changing A0 and A1. Pointers should initially * point right past the end of the longwords. * ******** Sub_BCD: andi #0,ccr sbcd -(a0),-(a1) sbcd -(a0),-(a1) sbcd -(a0),-(a1) sbcd -(a0),-(a1) rts ******************************************* DISPLAY A BCD NUMBER * * Displays D0+1 bytes of a BCD number at A0 in memory at A1. * * Modifies D0, D1, A0 - A2. * ******** Display_BCD: move.b (a0),d1 and.w #$f0,d1 lsr.w #4,d1 mulu #5,d1 lea digits(pc,d1.w),a2 moveq #4,d1 loop_copy: move.b (a2)+,d2 move.b d2,(a1) lea 32(a1),a1 dbra d1,loop_copy lea -160(a1),a1 move.b (a0)+,d1 and.w #$f,d1 mulu #5,d1 lea digits(pc,d1.w),a2 moveq #4,d1 loop_or: move.b (a2)+,d2 lsr.b #4,d2 or.b d2,(a1) lea 32(a1),a1 dbra d1,loop_or lea -159(a1),a1 dbra d0,Display_BCD rts digits: dc.b %01000000 dc.b %10100000 dc.b %10100000 dc.b %10100000 dc.b %01000000 dc.b %01000000 dc.b %01000000 dc.b %01000000 dc.b %01000000 dc.b %01000000 dc.b %01000000 dc.b %10100000 dc.b %00100000 dc.b %01000000 dc.b %11100000 dc.b %11000000 dc.b %00100000 dc.b %11000000 dc.b %00100000 dc.b %11000000 dc.b %10100000 dc.b %10100000 dc.b %11100000 dc.b %00100000 dc.b %00100000 dc.b %11100000 dc.b %10000000 dc.b %11000000 dc.b %00100000 dc.b %11000000 dc.b %01100000 dc.b %10000000 dc.b %11100000 dc.b %10100000 dc.b %11100000 dc.b %11100000 dc.b %00100000 dc.b %00100000 dc.b %01000000 dc.b %01000000 dc.b %01000000 dc.b %10100000 dc.b %01000000 dc.b %10100000 dc.b %01000000 dc.b %11100000 dc.b %10100000 dc.b %11100000 dc.b %00100000 dc.b %11000000 dc.b %01000000 dc.b %10100000 dc.b %11100000 dc.b %10100000 dc.b %10100000 dc.b %11000000 dc.b %10100000 dc.b %11000000 dc.b %10100000 dc.b %11000000 dc.b %11100000 dc.b %10000000 dc.b %10000000 dc.b %10000000 dc.b %11100000 dc.b %11000000 dc.b %10100000 dc.b %10100000 dc.b %10100000 dc.b %11000000 dc.b %11100000 dc.b %10000000 dc.b %11100000 dc.b %10000000 dc.b %11100000 dc.b %11100000 dc.b %10000000 dc.b %11100000 dc.b %10000000 dc.b %10000000