*12456789012345678901245678901234567890124567890123456789 #INCLUDE 'A:\VAR_DEF.ASM' * Define program variables ORG DATA S0 RMB 1 S1 RMB 1 S2 RMB 1 S3 RMB 1 S4 RMB 1 S5 RMB 1 S6 RMB 1 S7 RMB 1 STEP RMB 1 ; +1=FORWARD; -1=BACKWARD POINTER RMB 1 * Main program ORG PROGRAM START LDX #REGBAS * Initialize stepper motor sequence LDAA #$08 STAA S0 LDAA #$09 STAA S1 LDAA #$01 STAA S2 LDAA #$05 STAA S3 LDAA #$04 STAA S4 LDAA #$06 STAA S5 LDAA #$02 STAA S6 LDAA #$0A STAA S7 * Initialize controls LDAA #0 ; set stand still as default STAA STEP LDAA #$00 ; set pointer STAA POINTER * Start looping LABEL0 JSR STEP_SR BRA LABEL0 SWI * Step subroutine STEP_SR LDAB POINTER ; load pointer in B ADDB STEP ; add step to pointer -> B CMPB #7 ; check roof BLE LABEL3 ; bypass if the roof not hit yet LDAB #0 ; reset pointer to the bottom LABEL3 CMPB #0 ; check if bottomed out BGE LABEL4 ; jump if bottom not hit yet LDAB #7 ; reset pointer to the roof LABEL4 STAB POINTER ; store pointer LDY #$0000 ; zero Y ABY ; B+Y -> Y. We have the pointer in Y LDAA $00,Y ; load sequence code into accA from * : the location indicated by pointer STAA PORTB,X ; send sequence code to PORT B RTS ORG RESET ; reset vector FDB START ; set to start of program