crc16: banked wrapper for cross-bank callers

The lookup tables live in BANK1, so the routine switches the code bank to
reach them with movc and never switches it back. That is the contract the
__naked declaration already implied: same bank or common segment only.
The name now says it.

crc16_bank1 is the routine unchanged. crc16 becomes a __banked wrapper in
BANK1, so a caller from another bank has its own bank put back by
__sdcc_banked_ret. The two existing call sites take the direct path and
pay nothing.
This commit is contained in:
d00f committed 2026-09-09 01:52:12 +02:00
1 parent dd09be9dd0
commit 53f12a42c5
3 files changed
+12 -6

No files matched your search

+7 -1
View File
@@ -3,6 +3,8 @@
;
.globl _crc_value
.globl _crc16
.globl _crc16_bank1
.globl __sdcc_banked_ret
.equ BANK, 0x96
; .equ DPS, 0x86
; Variable in XMEM holding current CRC16 value, being updated
@@ -18,7 +20,7 @@ _crc_value::
.area HOME (CODE)
.area CSEG (CODE)
; .area BANK1 (CODE)
_crc16:
_crc16_bank1:
mov BANK, #1
push dph
push dpl
@@ -52,6 +54,10 @@ _crc16:
.area BANK1 (CODE)
_crc16:
lcall _crc16_bank1
ljmp __sdcc_banked_ret
crc16_table_l:
.byte #0x00, #0xc1, #0x81, #0x40, #0x01, #0xc0, #0x80, #0x41
.byte #0x01, #0xc0, #0x80, #0x41, #0x00, #0xc1, #0x81, #0x40