ORG $C000 INPUT EQU $FFAC OUTPORT EQU $1004 ;output port : Chip -> D/A : This is port B CTLPORT EQU $1003 ;I/O Port : Control D/A and A/D : This is port C DDRC EQU $1007 ;data direction register for port C INPORT EQU $100A ;input port : A/D -> Chip : This is port E MYDATA EQU $D000 ;location of data NUMSMP EQU #100 ;number of samples being taken ORG $C100 LDAA #$F7 STAA DDRC ;this sets all port C pins to output except pin 3, which is A/D "busy" LDAA #$C0 STAA CTLPORT ;initialize the control port so nothing is happening START LDAA #$C0 STAA CTLPORT ;initialize the control port so nothing is happening LOOP1 JSR INPUT ;listen to keyboard for start TSTA ;see if there is a key pressed BEQ LOOP1 ;if not, loop to start CMPA #$58 ;check for capital X BEQ GETDATA CMPA #$78 ;check for lowercase x BEQ GETDATA CMPA #$52 ;check for capital R BEQ SENDREV CMPA #$72 ;check for lowercase r BEQ SENDREV CMPA #$50 ;check for capital P BEQ SENDPLAY CMPA #$70 ;check for lowercase p BEQ SENDPLAY CMPA #$20 ;check for space BEQ FINISH BRA LOOP1 ;branch back to start if the input isn't one we want GOTOSTART BRA START GETDATA *start the conversion LDAA #$C7 ;set start conversion bit, RD, and CS high - keep D/A off STAA CTLPORT ;set the control register *set up the loop variable LDAB NUMSMP ;this will be used as a counter DECB ;this is here becuase to adjust the loop LDX MYDATA ;the start location for the data GETLOOP LDAA CTLPORT ;get current control status *check to see if A/D is busy ANDA #$08 ;AND with 8 to get nothing but the "busy" signal bit CMPA #$08 ;if true, then the busy signal is on BEQ GETLOOP ;if busy, keep waiting (branch to start of loop again) *if not busy... LDAA #$C1 ;set RD and CS to low so we can read data - keep D/A off STAA CTLPORT *the port is now ready to be read LDAA INPORT ;get the data from the port STAA $X ;store it in the data location INX ;increment X so we can store the next value *reset port so it starts conversion again LDAA #$C7 ;set start conversion bit, RD, and CS high - keep D/A off STAA CTLPORT ;set the control register DECB ;decrement the counter TSTB BEQ START ;if counter is 0, all data is collected, go to start and wait BRA GETLOOP ;if counter is not 0, keep getting data SENDPLAY LDAA #$00 STAA CTLPORT ;initialize the control port so D/A is running LDAB NUMSMP ;this will be used as a counter DECB ;this is here becuase to adjust the loop LDX MYDATA ;the start location for the data SPLOOP LDAA $X ;load data at location stored in register X STAA OUTPORT ;write data to D/A converter INX ;increment X DECB ;decrement counter TSTB BEQ START ;if counter is 0, all data is collected, go to start and wait BRA SPLOOP ;if counter is not 0, keep getting data SENDREV LDAA #$00 STAA CTLPORT ;initialize the control port so D/A is running LDD MYDATA ;the start location for the data ADDD NUMSMP ;since we're working backwards, add number of samples STD $X ;store in X DEX ;then decrement X to point at the last data point LDAB NUMSMP ;this will be used as a counter DECB ;this is here becuase to adjust the loop SRLOOP LDAA $X ;load data at location stored in register X STAA OUTPORT ;write data to D/A converter DEX ;increment X DECB ;decrement counter TSTB BEQ GOTOSTART ;if counter is 0, all data is collected, go to start and wait BRA SRLOOP ;if counter is not 0, keep getting data FINISH RTS END