ack/mach/6500/libem/sri.s
1987-01-30 18:41:42 +00:00

46 lines
787 B
ArmAsm

.define Sri2, Sru2
.sect .text
.sect .rom
.sect .data
.sect .bss
.sect .text
! The subroutine Sri2 shifts a signed integer n times right.
! In the case of a negative integer there is signextension.
! The subroutine Sru2 shifts right an unsigned integer.
! The returned value is in registerpair AX.
Sru2:
txa
bne 1f
jmp Pop ! zero shift, return input
1: tay
jsr Pop ! get integer
stx Ytmp ! save lowbyte
jmp 2f ! shift unsigned
Sri2:
txa
bne 1f
jmp Pop ! zero shift, return input
1: tay
jsr Pop ! get integer
stx Ytmp ! save lowbyte
tax
bmi 1f ! negative signextended shift
2: lsr a
ror Ytmp ! shift not signextended
dey
bne 2b
ldx Ytmp ! get lowbyte
rts
1: sec ! shift signextended
ror a
ror Ytmp
dey
bne 1b
ldx Ytmp ! get lowbyte
rts