Classic Computer Magazine Archive PROGRAM LISTING: 84-09/ROTATE.ASM


10   *=$600
20 ;
30 ; -------------------------------
40 ; A=USR(ML,ADR,# BYTES,DIRECTION)
50 ;
60 ; ROTATES DATA LEFT OR RIGHT
70 ;
80 ; -------------------------------
90 ;
0100 ADR   = $CB
0110 BYTES = $CD
0120 DIR   = $CE
0130  PLA             ; IGNORE
0140  PLA             ; GET HI BYTE OF ADDRESS
0150  STA ADR+1
0160  PLA            ; GET LO BYTE OF ADDRESS
0170  STA ADR
0180  PLA            ; IGNORE
0190  PLA            ; GET NUMBER OF BYTES
0200  STA BYTES
0210  PLA            ; IGNORE
0220  PLA            ; GET DIRECTION
0230  STA DIR
0240 ;
0250  LDY #0
0260 LOOP CLC
0270  LDA DIR
0280  BNE RIGHT      ; RIGHT IF A 1
0290 ;
0300 LEFT LDA (ADR),Y
0310  ASL A          ; SHIFT LEFT
0320  BCC STORE      ; NO CARRY BIT
0330  CLC
0340  ADC #1         ; SET BIT 0
0350  CLC
0360  BCC STORE
0370 RIGHT LDA (ADR),Y
0380  LSR A          ; SHIFT RIGHT
0390  BCC STORE      ; NO CARRY BIT
0400  CLC
0410  ADC #128       ; SET BIT 7
0420 STORE STA (ADR),Y
0430  INY
0440  CPY BYTES      ; DONE?
0450  BNE LOOP       ; NO
0460  RTS            ; YES- RETURN TO BASIC

Back to previous page