danwinslow Posted January 2, 2011 Share Posted January 2, 2011 Anyone have a ML routine to convert jiffies ( from the RTC at 18/19/20 ) into seconds handy? Quote Link to comment Share on other sites More sharing options...
Chilly Willy Posted January 3, 2011 Share Posted January 3, 2011 Instead of dividing the jiffies by 50/60, perhaps it would be better to add your own VB handler and increment a seconds variable every 50/60 ints. Quote Link to comment Share on other sites More sharing options...
danwinslow Posted January 3, 2011 Author Share Posted January 3, 2011 Perhaps it would, but that's not the question Quote Link to comment Share on other sites More sharing options...
Rybags Posted January 3, 2011 Share Posted January 3, 2011 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. Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted January 3, 2011 Share Posted January 3, 2011 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.