xdef pgstart absentry pgstart * ******************************************************************************* * Macros * PORTB equ $0001 DDRB equ $0003 SCHBDH equ $00C8 SCHBDL equ $00C9 SCICR2 equ $00CB SCISR1 equ $00CC SCIDRL equ $00CF CRGFLG equ $0037 CRGINT equ $0038 RTICTL equ $003B * ******************************************************************************* * RTI Vector Section: [ $FFF0 to $FFF1 ] * org $FFF0 dc.w RTIISR * ******************************************************************************* * Data Section: [ $3000 to $30FF ] * org $3000 counter dc.w $0000 msg dc.b 'This program will print a $ every second',$00 numBuf ds.b $0002 dc.b $00 inNumBuf dc.w $0000 * ******************************************************************************* * Program Section: [ $3100 to $3FFF ] * org $3100 pgstart lds #pgstart ldaa #1 staa SCHBDH ldaa #$0C staa SCICR2 ldaa #%00011001 staa RTICTL bset CRGINT,#%10000000 bset CRGFLG,#%10000000 ldx #msg jsr printmsg cli loop jsr getchar tsta beq loop jsr putchar bra loop ;****************************************************************************** ; Subroutine Section ; RTIISR bset CRGFLG,#%10000000 ldx counter inx stx counter cpx #400 bne RTIDONE ldx #0 stx counter ldaa #'$' jsr putchar RTIDONE rti getchar brclr SCISR1,#%00100000,empty ldaa SCIDRL rts empty clra rts PrintTwoDigitDecimal pshx pshd pshy ldy #numBuf ConvertLoop ldx #10 idiv cpd #0 beq CheckX XNotZero addb #'0' stab 1,y+ exg d,x bra ConvertLoop CheckX cpx #0 bne XNotZero ldx #numBuf jsr printmsg puly puld pulx rts ReadTwoDigitDecimal pshx pshd pshy ldd #0 ldab 1,x+ beq ReadDone cmpb #'0' blt ReadDone cmpb #'9' bhi ReadDone pshb ldd inNumBuf ldy #10 emul std inNumBuf pulb subb #'0' ldy inNumBuf aby sty inNumBuf bra ReadLoop ReadDone puly puld pulx rts putchar brclr SCISR1,#%10000000,putchar staa SCIDRL rts printmsg pshx psha printLoop ldaa 1,x+ beq printDone jsr putchar bra printLoop printDone pula pulx rts ; ;****************************************************************************** end