bogax #1 Posted August 29, 2014 (edited) edit: Multiply is buggy! I forgot to propagate the carry Here is a replacement for the 8 * 8 = 16 multiplication and 8 / 8 division with remainder routines. I haven't tested them exhaustively yet but they seem to work ; enter with multipcands in a, y ; a * b result hi in temp2, lo in a ; by bogax mul16 dey sty temp1 sta temp2 ldx #$07 lda #$00 mul_loop asl rol temp2 bcc mul_no_add adc temp1 mul_no_add dex bpl mul_loop rts ; a / y ; returns quotient in a, remainder in y and temp1, divisor in temp2 ; by bogax div16 sty temp2 ; divisor asl ; dividend sta temp1 ; quotient/dividend lda #$00 ldx #$07 div_loop rol ; remainder cmp temp2 ; divisor bcc div_next sbc temp2 ; divisor div_next rol temp1 ; quotient/dividend dex bpl div_loop tay lda temp1 sty temp1 rts Edited August 31, 2014 by bogax Quote Share this post Link to post Share on other sites