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

32 lines
508 B
ArmAsm

.define Rol
.sect .text
.sect .rom
.sect .data
.sect .bss
.sect .text
! This subroutine rotates left an integer n times
! N is in register X.
! The result is returned in registerpair AX.
Rol:
txa
bne 1f
jmp Pop ! zero rotate return input
1: tay ! Y contains number of rotates
jsr Pop
stx Ytmp ! save lowbyte
2: clc
rol Ytmp ! rotate lowbyte
rol a ! rotate highbyte
bcc 1f ! no carry
inc Ytmp ! put carry in rightmost bit
1: dey
bne 2b
ldx Ytmp ! store lowbyte in X
rts