AS09 Assembler for M6809/H6309 [1.08]. Page 1 -------------------------------- TAPEBITS.ASM -------------------------------- 88 lines read, no errors in pass 1. ****************************************************** * TAPEBITS * Read cassette data, record duration of each bit phas * * The buffer contains 2-byte ints, each of which is th * number of loops during a bit phase (ie: how long it * 0, or how long it was 1). Each loop is 28 clock cyc * or about one 31960th of a second. So a '1' bit at 2 * should be about 13.32 loops for the entire bit, or 6 * for each phase; and a '0' bit at 1200Hz should be ab * 26.63 loops per bit, or 13.32 loops per phase. * So when recieving valid cassette data, the numbers f * each phase should be 6, 7, 13, or 14. ****************************************************** ff20 = PIA1AD equ $FF20 ; PIA 1, side A, Data register 0010 = IRQ equ $10 0040 = FIRQ equ $40 05ff = ACTIVE equ $05FF ; lower right character on screen 4000 = buffer equ $4000 ; where to store results 8000 = endbuf equ $8000 3000 = org $3000 3000 = start equ * 3000 : 2012 bra start2 3002 : 9908251810 fcb $99,$08,$25,$18,$10 3007 : 54415045424954.. fcc "TAPEBITS V0.1" 3014 = start2 equ * 3014 : 1a50 orcc #IRQ|FIRQ ; disable interrupts 3016 : 10bf3104 sty tmp_y ; save .y 301a : 8e4000 ldx #buffer 301d : 7f3103 clr over ; no overflows yet 3020 : b6ff20 lda PIA1AD 3023 : 8401 anda #1 ; look at cassette input bit 3025 = new equ * 3025 : b73102 sta prev ; 5 ; remember if it is 0 or 1 3028 : 108e0001 ldy #1 ; 4 ; initialize counter * Since each phase has an overhead of 32 cycles (new + * we count one additional loop. Loops take 28 cycles e * so this is pretty close. 302c = same equ * 302c : 3121 leay 1,y ; 5 302e : 108cffff cmpy #$FFFF ; 5 ; counter overflow? 3032 : 271f beq overflow ; 3 3034 : b6ff20 lda PIA1AD ; 5 3037 : 8401 anda #1 ; 2 ; look at cassette input bit 3039 : b13102 cmpa prev ; 5 ; compare with previous 303c : 27ee beq same ; 3 ; not changed yet; count more * -- * 28 303e = diff equ * 303e : 7c05ff inc ACTIVE ; 7 ; show that we're waiting 3041 : 10af81 sty ,x++ ; 9 ; phase changed, save count 3044 : 8c8000 cmpx #endbuf ; 4 ; buffer full? 3047 : 26dc bne new ; 3 ; if not, count more AS09 Assembler for M6809/H6309 [1.08]. Page 2 -------------------------------- TAPEBITS.ASM -------------------------------- * -- * 23 3049 = done equ * 3049 : bf3100 stx last 304c : 108e3104 ldy #tmp_y ; restore .y 3050 : 1caf andcc #~(IRQ|FIRQ) ; re-enable interrupts 3052 : 39 rts 3053 = overflow equ * 3053 : b63103 lda over 3056 : 4c inca ; another overflow 3057 : 811e cmpa #30 ; too many? 3059 : 24ee bhs done ; if so, exit 305b : b73103 sta over ; not too many yet 305e : b63102 lda prev ; still the same bit value 3061 : 20db bra diff ; continue counting 3100 = org $3100 3100 : 0000 last fdb 0 ; last address filled + 2 3102 : 00 prev fcb 0 ; last known value of cassette bit 3103 : 00 over fcb 0 ; number of counter overflows 3104 : 0000 tmp_y fdb 0 ; .y saved here on entry 3104 = end start No errors in pass 2.