Add another entry point to the shift left routine, that shifts A/X by Y
without going over the stack. git-svn-id: svn://svn.cc65.org/cc65/trunk@5742 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
e3fb0233c8
commit
b9ffe5de13
1 changed files with 49 additions and 24 deletions
|
@ -11,45 +11,70 @@
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
.export tosaslax, tosshlax
|
.export tosaslax, tosshlax, aslaxy, shlaxy
|
||||||
.import popax
|
.import popax
|
||||||
.importzp tmp1
|
.importzp tmp1
|
||||||
|
|
||||||
|
.macpack cpu
|
||||||
|
|
||||||
tosshlax:
|
tosshlax:
|
||||||
tosaslax:
|
tosaslax:
|
||||||
and #$0F ; Bring the shift count into a valid range
|
sta tmp1 ; Save shift count it
|
||||||
sta tmp1 ; Save it
|
|
||||||
|
|
||||||
jsr popax ; Get the left hand operand
|
jsr popax ; Get the left hand operand
|
||||||
|
|
||||||
ldy tmp1 ; Get shift count
|
ldy tmp1 ; Get shift count
|
||||||
beq L9 ; Bail out if shift count zero
|
|
||||||
|
|
||||||
cpy #8 ; Shift count 8 or greater?
|
; Run into shlaxy
|
||||||
bcc L3 ; Jump if not
|
|
||||||
|
|
||||||
; Shift count is greater 7. The carry is set when we enter here.
|
shlaxy:
|
||||||
|
aslaxy:
|
||||||
tax
|
pha
|
||||||
tya
|
tya
|
||||||
sbc #8
|
and #$0F
|
||||||
tay
|
beq L2 ; Nothing to shift
|
||||||
txa
|
sec
|
||||||
jmp L2
|
sbc #8 ; Shift count 8 or greater?
|
||||||
|
beq L3 ; Jump if exactly 8
|
||||||
|
bcc L4 ; Jump if less than 8
|
||||||
|
|
||||||
|
; Shift count is greater than 8.
|
||||||
|
|
||||||
|
tay ; Shift count into Y
|
||||||
|
pla ; Get low byte
|
||||||
|
|
||||||
L1: asl a
|
L1: asl a
|
||||||
L2: dey
|
dey
|
||||||
bpl L1
|
bne L1
|
||||||
tax
|
tax
|
||||||
lda #$00
|
tya ; A = 0
|
||||||
rts
|
rts
|
||||||
|
|
||||||
; Shift count is less than 8.
|
; Shift count is zero
|
||||||
|
|
||||||
L3: stx tmp1 ; Save high byte of lhs
|
L2: pla
|
||||||
L4: asl a
|
rts
|
||||||
|
|
||||||
|
; Shift count is exactly 8
|
||||||
|
|
||||||
|
.if (.cpu .bitand CPU_ISET_65SC02)
|
||||||
|
L3: plx ; Low byte from stack into X
|
||||||
|
rts ; A is already zero
|
||||||
|
.else
|
||||||
|
L3: pla ; Low byte from stack ...
|
||||||
|
tax ; ... into X
|
||||||
|
lda #$00 ; Clear low byte
|
||||||
|
rts
|
||||||
|
.endif
|
||||||
|
|
||||||
|
; Shift count is less than 8
|
||||||
|
|
||||||
|
L4: adc #8 ; Correct counter
|
||||||
|
tay ; Shift count into Y
|
||||||
|
pla ; Restore low byte
|
||||||
|
stx tmp1 ; Save high byte of lhs
|
||||||
|
L5: asl a
|
||||||
rol tmp1
|
rol tmp1
|
||||||
dey
|
dey
|
||||||
bne L4
|
bne L5
|
||||||
|
|
||||||
; Done with shift
|
; Done with shift
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue