Skip to content

Commit 17b7387

Browse files
committed
combine lshrs and lshru into one file
1 parent b2c8d81 commit 17b7387

2 files changed

Lines changed: 30 additions & 34 deletions

File tree

src/crt/lshrs.src

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
.section .text
44
.global __lshrs
55
.type __lshrs, @function
6-
.global __lshrs.hijack_lshru
7-
.type __lshrs.hijack_lshru, @function
86

97
.ifdef PREFER_OS_CRT
108

@@ -27,6 +25,7 @@ __lshrs:
2725
add hl, sp
2826
.L.loop:
2927
sra a
28+
.local __lshrs.hijack_lshru
3029
__lshrs.hijack_lshru:
3130
inc hl
3231
inc hl
@@ -40,4 +39,33 @@ __lshrs.hijack_lshru:
4039
pop hl
4140
ret
4241

42+
.endif
43+
44+
.section .text
45+
.global __lshru
46+
.type __lshru, @function
47+
48+
.ifdef PREFER_OS_CRT
49+
50+
.set __lshru, 0x0001EC
51+
52+
.else
53+
54+
__lshru:
55+
; Suboptimal for large shift amounts
56+
; CC: if C!=0: C*(15*r(PC)+3*r(SPL)+3*w(SPL)+4)+17*r(PC)+9*r(SPL)+6*w(SPL)+2
57+
; if C==0: 4*r(PC)+3*r(SPL)+2
58+
inc l
59+
dec l
60+
ret z
61+
push hl
62+
push bc
63+
ld b, l
64+
or a, a
65+
sbc hl, hl
66+
add hl, sp
67+
.L.loop:
68+
srl a
69+
jr __lshrs.hijack_lshru
70+
4371
.endif

src/crt/lshru.src

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)