ack/mach/6500/libem/sri.s

46 lines
787 B
ArmAsm
Raw Permalink Normal View History

1984-12-17 11:03:13 +00:00
.define Sri2, Sru2
1987-01-30 18:41:42 +00:00
.sect .text
.sect .rom
.sect .data
.sect .bss
.sect .text
1984-12-17 11:03:13 +00:00
! 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