VICE speed

You need an actual VIC.

Moderator: Moderators

Post Reply
User avatar
toby405
Vic 20 Amateur
Posts: 46
Joined: Fri Dec 21, 2012 8:33 pm
Location: USA

VICE speed

Post by toby405 »

I wrote the following program to initialize RAM in the "user basic area", just for the fun of it. It runs really fast, like almost instantly. I know VICE tries to simulate speed of processor cycles. I don't have a real VIC up and running well enough yet to try this. Is the 6502 really that fast or is VICE not as accurate on something like this?

Code: Select all

        processor 6502
        org $1001               ; Unexpanded VIC

        ; BASIC stub (unexpanded vic)   
        dc.w $100b              ; Pointer to next BASIC line
        dc.w 1981               ; BASIC Line#
        dc.b $9e                ; BASIC SYS token
        dc.b $34,$31,$30,$39    ; 4109 (ML start)
        dc.b 0                  ; End of BASIC line
        dc.w 0                  ; End of BASIC program

; initialize user basic area of ram
; $1000-$1dff

        lda #$00
        sta $00fb
        lda #$10
        sta $00fc
        
        lda #$0
        ldy #<start         ; start after this program
.1      sta ($fb),Y
        iny
        bne .1
        ldx $fc
        inx
        cpx #$1e
        beq .2
        stx $fc
        jmp .1
.2      rts
start
User avatar
buzbard
Vic 20 Devotee
Posts: 213
Joined: Sun Jul 03, 2005 9:10 am

Post by buzbard »

The real VIC is only 1Mhz, but yes, it really is quite that fast.
VICE is quite accurate in that respect.
Ray..
User avatar
Mike
Herr VC
Posts: 4831
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: VICE speed

Post by Mike »

toby405 wrote:[...] Is the 6502 really that fast [...]?

Code: Select all

        [...]
.1      sta ($fb),Y
        iny
        bne .1
        [...]
These three lines are executed most of the time and need 6 (STA(),Y) + 2 (INY) + 3 (executed BNE) = 11 cycles per iteration, for 256 iterations (except for a few missing bytes in the first page) per page, and 14 pages in total.

11x256x14 ~= 40000 cycles.

On a 6502 running at 1 MHz, that takes 40 milliseconds.
User avatar
toby405
Vic 20 Amateur
Posts: 46
Joined: Fri Dec 21, 2012 8:33 pm
Location: USA

Post by toby405 »

That's awesome. I should have thought of counting the cycles.
Post Reply