I used some unsigned integer multiply routines from codebase64.
Now I would like to compare some signed integer multiply rotines.
But how can I print the multiplier, multiplicand and result on screen with the sign - ?
As an example there is the code of my unsigned routine.
Code: Select all
; mult39.a
; from https://revs.bbcelite.com/source/main/subroutine/multiply8x8.html
; From 'Revs' for the BBC Micro
; tweaked a bit for size and speed
;
; 8 bit x 8 bit unsigned multiply, 16 bit result
; Average cycles: 107
; 69 bytes
; (A T) = A * U
FLPASC equ $DDDD
INTFLP equ $D391
CLRSCR equ $E55F
WRTF equ $E742
STROUT equ $CB1E
STACK equ $0100
u equ $30 ; multiplicand
multiplier equ $32
t equ $34 ;
producthigh equ $36
*=$1201
dB $0B, $12, $0A, $00, $9E
dB $38, $31, $39, $32 ; SYS8192 = $2000
dB $00, $00, $00
*=$2000
sei ; stop interrupts
jsr CLRSCR ; clear screen
lda #$00 ; high
ldy #155 ; low
sty multiplier
jsr INTFLP ; integer to float point
jsr Primm
db "MULTIPLIER: ",$00
jsr FLPASC
ldy #>STACK
lda #<STACK
jsr STROUT
lda #$00 ; high
ldy #155 ; low
sty u
jsr INTFLP ; integer to float point
jsr Primm
db $0d,"MULTIPLICAND:",$00
jsr FLPASC
ldy #>STACK
lda #<STACK
jsr STROUT
; code from the book VIC-20 MACHINE LANGUAGE GUIDE Abacus Software
lda #0
sta $9129 ; decrements every 256 µS ; 4 cycles
sta $9128 ; decrements every µS ; 4 cycles
cld ; insure binary mode ; 2 cycles
clc ; clear carry flag ; 2 cycles
; ************** Start Counter with 10 Cycles ********************
; ***************************************************************************************
; On Entry:
; A: multiplier
; u: multiplicand
; On Exit:
; t: low byte of product
; A: high byte of product
lda multiplier
Multiply8x8:
lsr
sta t
lda #0
bcc next1
lda u
lsr
next1:
ror t
bcc next2
clc
adc u
next2:
ror
ror t
bcc next3
clc
adc u
next3:
ror
ror t
bcc next4
clc
adc u
next4:
ror
ror t
bcc next5
clc
adc u
next5:
ror
ror t
bcc next6
clc
adc u
next6:
ror
ror t
bcc next7
clc
adc u
next7:
ror
ror t
bcc next8
clc
adc u
next8:
ror
ror t
sta producthigh
; ************** Stop Counter ********************
lda $9128
sta $FB
lda producthigh
ldy t
jsr INTFLP ; integer to float point
jsr Primm
db $0d,$0d,"SOLUTION:",$00
jsr FLPASC
ldy #>STACK
lda #<STACK
jsr STROUT
lda #$FF
sbc $FB
sbc #10
tay ; low
lda #0
jsr INTFLP ; integer to float point
jsr Primm
db $0d,$0d,$0d,"CYCLES:",$00
jsr FLPASC
ldy #>STACK
lda #<STACK
jsr STROUT
jmp * ; infinity jump
Primm:
pla
sta $03
pla
sta $04
X10D6:
inc $03
bne X10DC
inc $04
X10DC:
ldy #$00
lda ($03),y
beq X10E7
jsr WRTF
bcc X10D6
X10E7:
lda $04
pha
lda $03
pha
rts
Maybe someone has an working routine for me or some tips.
Best regards
Sven