I was comparing the speed of different integer multiplications. A small routine for measuring the cycles came out. This uses only the first of two counters $9128. The second counter would have to be implemented for longer cycle times.
I don't know why 10 cycles are used to start.
Maybe someone can use this routine.
Code: Select all
FLPASC equ $DDDD
INTFLP equ $D391
CLRSCR equ $E55F
WRTF equ $E742
STROUT equ $CB1E
STACK equ $0100
* = $1001
; BASIC program to boot the machine language code
db $0b, $10, $0a, $00, $9e, $34, $31, $30, $39, $00, $00, $00
sei ; stop interrupts
jsr CLRSCR ; clear screen
; code from the book VIC-20 MACHINE LANGUAGE GUIDE Abacus Software
lda #0
sta $9129
sta $9128 ; 4 cycles
cld ; 2 cycles
clc ; 2 cycles
; ---------
; 10 cycles ??? WHY ???
; =========
; ************** Start Counter with 10 Cycles ********************
lda #$05 ; 2 cycles
sta $FB ; 3 cycles
ldx #$01 ; 2 cycles
lda $FB,x ; 4 cycles
nop ; 2 cycles
; ---------
; 13 cycles
; =========
; ************** Stop Counter ********************
lda $9128
sta $FB
lda #$FF
sbc $FB
sbc #10 ; subtract the 10 cycles from start
tay ; low
lda #$00 ; high
jsr INTFLP ; integer to float point
jsr Primm
db "CYCLES:",$00
jsr FLPASC
ldy #>STACK
lda #<STACK
jsr STROUT
jmp *
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