mirror of
https://github.com/cc65/cc65.git
synced 2024-12-27 15:29:46 +00:00
c122f18605
git-svn-id: svn://svn.cc65.org/cc65/trunk@3143 b7a2c559-68d2-44c3-8de9-860c34a00d81
45 lines
1.1 KiB
ArmAsm
45 lines
1.1 KiB
ArmAsm
;
|
|
; Ullrich von Bassewitz, 2004-06-30
|
|
;
|
|
; CC65 runtime: right shift support for longs
|
|
;
|
|
; Note: The standard declares a shift count that is negative or >= the
|
|
; bitcount of the shifted type for undefined behaviour.
|
|
;
|
|
; Note^2: The compiler knowns about the register/zero page usage of this
|
|
; function, so you need to change the compiler source if you change it!
|
|
;
|
|
|
|
|
|
.export tosasreax
|
|
.import popeax
|
|
.importzp sreg, tmp1
|
|
|
|
|
|
tosasreax:
|
|
and #$1F ; Bring the shift count into a valid range
|
|
sta tmp1 ; Save it
|
|
|
|
jsr popeax ; Get the left hand operand
|
|
|
|
ldy tmp1 ; Get shift count
|
|
beq L9 ; Bail out if shift count zero
|
|
stx tmp1 ; Save byte 1
|
|
ldx sreg+1 ; Load byte 3
|
|
|
|
; Do the actual shift. Faster solutions are possible but need a lot more code.
|
|
|
|
L2: cpx #$80 ; Copy bit 31 into the carry
|
|
ror sreg+1
|
|
ror sreg
|
|
ror tmp1
|
|
ror a
|
|
dey
|
|
bne L2
|
|
|
|
; Shift done
|
|
|
|
ldx tmp1
|
|
L9: rts
|
|
|