Merge pull request #2390 from colinleroy/implement-shifts-by-7

Implement aslax7/shlax7/asrax7/shrax7
This commit is contained in:
Bob Andrews
2024-02-02 20:17:48 +01:00
committed by GitHub
9 changed files with 253 additions and 0 deletions

21
libsrc/runtime/aslax7.s Normal file
View File

@@ -0,0 +1,21 @@
;
; Miloslaw Smyk, 2024
;
; CC65 runtime: Scale the primary register by 128, unsigned
;
.export shlax7, aslax7
aslax7:
shlax7: ; XXXXXXXL AAAAAAAl
tay
txa
lsr ; XXXXXXXL -> 0XXXXXXX, L->C
tya
ror ; AAAAAAAl -> LAAAAAAA, l->C
tax
lda #$00 ; LAAAAAAA 00000000
ror ; LAAAAAAA l0000000
rts
; 10 bytes, 16 cycles + rts

18
libsrc/runtime/asrax7.s Normal file
View File

@@ -0,0 +1,18 @@
;
; Miloslaw Smyk, 2024
;
; CC65 runtime: Scale the primary register by 128, signed
;
.export asrax7
asrax7: ; HXXXXXXL hAAAAAAl
asl ; AAAAAAA0, h->C
txa
rol ; XXXXXXLh, H->C
ldx #$00 ; 00000000 XXXXXXLh
bcc :+
dex ; 11111111 XXXXXXLh if C
: rts
; 12 cycles max, 9 bytes

18
libsrc/runtime/shrax7.s Normal file
View File

@@ -0,0 +1,18 @@
;
; Miloslaw Smyk, 2024
;
; CC65 runtime: Scale the primary register by 128, unsigned
;
.export shrax7
shrax7: ; HXXXXXXL hAAAAAAl
asl ; AAAAAAA0, h->C
txa
rol ; XXXXXXLh, H->C
ldx #$00 ; 00000000 XXXXXXLh
bcc :+
inx ; 0000000H XXXXXXLh if C
: rts
; 12 cycles max, 9 bytes