Re: [cc65] need help getting external long from asm

From: Marc Rintsch <marc1rintsch.de>
Date: 2011-11-23 12:57:09
On Wednesday 23 November 2011 10:00:23 you wrote:
> On 23.11.11 01:56, Egan Ford wrote:
> > _timer: LDA     KBDCR           ; cycles 4      got key?
> > 
> >          BMI     DONE            ; cycles 2      if neg, got key goto
> >          DONE CLC                     ; cycles 2      clear carry
> >          LDA     #1              ; cycles 2      A = 1
> >          ADC     _count          ; cycles 4      LSB += A
> >          STA     _count          ; cycles 4
> >          LDA     #0              ; cycles 2      A = 0
> >          ROL     A               ; cycles 2      A = carry, carry = 0
> >          ADC     _count+1        ; cycles 4
> >          STA     _count+1        ; cycles 4
> >          LDA     #0              ; cycles 2      A = 0
> >          ROL     A               ; cycles 2      A = carry, carry = 0
> >          ADC     _count+2        ; cycles 4
> >          STA     _count+2        ; cycles 4
> >          LDA     #0              ; cycles 2      A = 0
> >          ROL     A               ; cycles 2      A = carry, carry = 0
> >          ADC     _count+3        ; cycles 4
> >          STA     _count+3        ; cycles 4
> >          CLC                     ; cycles 2      clear carry
> >          BCC     _timer          ; cycles 2 + 1  back to checking for key
> >          
> >                                  ; total = 59
> > 
> > DONE:   LDA     KBDDATA         ; get key value
> > 
> >          STA     _key            ; store in _key
> >          RTS
> 
> A small optimization, you can remove the "ROL A" instructions.

Even more optimization: All ``adc``/``sta`` can be replaced by 
``inc``/``bne``:

_timer: lda KBDCR
        bmi DONE
        inc _count
        bne _timer
        inc _count+1
        bne _timer
        inc _count+2
        bne _timer
        inc _count+3
        jmp _timer

DONE:   lda KBDDATA
        sta _key
        rts
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Nov 23 13:04:30 2011

This archive was generated by hypermail 2.1.8 : 2011-11-23 13:04:33 CET