* Ex_Sort.ASM *12456789012345678901245678901234567890124567890123456789 #INCLUDE 'A:\VAR_DEF.ASM' * Define program variables ORG DATA STEP RMB 1 ; +1=FORWARD; -1=BACKWARD DELAY RMB 1 ; $28 < DELAY < $ff * Main program ORG PROGRAM START LDX #REGBAS * Initialize SCI LDAA #%00110000 ; initialize BAUD=9600 STAA BAUD,X LDAA #%00000000 ; initialize 8-bit word STAA SCCR1,X LDAA #%00001100 ; initialize TE and RE STAA SCCR2,X * Initialize controls LDAA #0 ; set stand still as default STAA STEP LDAA #$ff ; set slow (DELAY=$ff) as default STAA DELAY * Start looping LABEL0 NOP * Check for keystroke reception LABEL1 LDAA SCSR,X ; check if RDRF is set ANDA #%00100000 ; mask for RDRF BEQ LABEL9 * You are here after the keystroke was received LDAB SCDR,X ; load keystroke * Echo the keystroke LABEL2 LDAA SCSR,X ; check if TDRE is set ANDA #%10000000 ; mask for TDRE BEQ LABEL2 * You are here when the transmission reg. is empty STAB SCDR,X ; transmit back keystroke * Decipher and sort keystroke CMPB #'>' BEQ FORWD CMPB #'<' BEQ BACKWD CMPB #'+' BEQ FASTER CMPB #'-' BEQ SLOWER CMPB #'S' BEQ STOP JMP LABEL9 FORWD LDAA STEP CMPA #+1 BGT LABL10 INCA LABL10 STAA STEP JMP LABEL9 BACKWD LDAA STEP CMPA #-1 BLT LABL11 DECA LABL11 STAA STEP JMP LABEL9 FASTER LDAA DELAY ; reduce delay CMPA #$28 ; but not below $28 BLS LABEL6 DECA LABEL6 STAA DELAY JMP LABEL9 SLOWER LDAA DELAY ; increase delay CMPA #$ff ; but not over $ff BHS LABEL7 INCA LABEL7 STAA DELAY JMP LABEL9 STOP SWI LABEL9 BRA LABEL0 ; back to the top ORG RESET ; reset vector FDB START ; set to start of program