From d229d51be5901d7b57ea831c663c130d83a9f8e9 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 16 Jul 2015 16:54:40 +0200 Subject: [PATCH] make sure clocktick starts at zero --- libsrc/pce/clock.s | 32 +++++++++++++++++++++----------- libsrc/pce/crt0.s | 4 ++-- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/libsrc/pce/clock.s b/libsrc/pce/clock.s index 6f939f078..5d0aa78f4 100644 --- a/libsrc/pce/clock.s +++ b/libsrc/pce/clock.s @@ -2,20 +2,30 @@ ; clock_t clock (void); ; - .include "pce.inc" + .include "pce.inc" - .export _clock - .importzp sreg -;; .importzp tickcount + .export _clock + .importzp sreg +;; .importzp tickcount .proc _clock - lda tickcount+3 - sta sreg+1 - lda tickcount+2 - sta sreg - ldx tickcount+1 - lda tickcount - rts + lda tickcount+3 + sta sreg+1 + lda tickcount+2 + sta sreg + ldx tickcount+1 + lda tickcount + rts .endproc + + .constructor initclock, 24 + +initclock: + lda #0 + ldx #3 +@lp: sta tickcount,x + dex + bpl @lp + rts \ No newline at end of file diff --git a/libsrc/pce/crt0.s b/libsrc/pce/crt0.s index e456bdeac..2b8455a59 100644 --- a/libsrc/pce/crt0.s +++ b/libsrc/pce/crt0.s @@ -88,8 +88,6 @@ start: lda #$05 sta IRQ_MASK ; IRQ1=on - cli - ; Clear the BSS data jsr zerobss @@ -141,6 +139,8 @@ start: ; Call module constructors jsr initlib + cli ; allow IRQ only after constructors have run + ; Pass an empty command line jsr push0 ; argc jsr push0 ; argv -- 2.39.5