Jump to content
IGNORED

jiffies to seconds


Recommended Posts

Yep, standard practice is to just use a VBI that does it's own counting to 50 or 60.

 

Converting RTCLOCK to seconds would require dividing a 24-bit unsigned binary by 50 or 60.

 

Maybe hit up 6502.org, they should have some code that does binary division. You'd probably need to modify a 16-bit divide to work on 24-bit numbers.

Link to comment
Share on other sites

This is from my IDEDIAG program. It uses the FP package to work out elapsed time and put the result in LBUFF:

 

get_elapsed ; figure out elapsed time
lda rtclok+2
sec
sbc start_time+2
sta elapsed
lda rtclok+1
sbc start_time+1
sta elapsed+1
lda rtclok
sbc start_time
sta elapsed+2
;
lda secdiv ; comvert secdiv to FP
sta fr0
lda #0
sta fr0+1
jsr ifp
ldx float_p
ldy float_p+1
jsr flstor ; save seconds multiplier

lda elapsed ; convert elapsed to FP
sta fr0
lda elapsed+1
sta fr0+1
jsr ifp
jsr fmove ; move jiffies to fr1
lda test_kb
sta fr0
lda #0
sta fr0+1 ; 1024 in fr0
jsr ifp ; convert to FP
jsr fdiv ; divide 1024 by elapsed jiffies

ldx float_p
ldy float_p+1
jsr fld1r ; put multiplier in fr1
jsr fmul ; multiply, put result in fr0
jsr fasc

 

Before starting your benchmark or whatever, just copy the RTC registers into START_TIME. SECDIV is derived thus:

 

get_secdiv
lda vcount
beq get_secdiv
wait2
tay
lda vcount
bne wait2; VCount = zero, but we've saved the largest possible in Y
cpy #131 ; NTSC will never get this high
bcc ntsc
lda #50
sta secdiv
rts
ntsc
lda #60
sta secdiv
rts

 

It's developmental code and probably buggy, and I don't know if it will suit your purposes.

 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...