From 87ae766a4458dc9d54daa570ac6b6bcb04a3ae0e Mon Sep 17 00:00:00 2001 From: Robert Steffens <39485357+ki-bo@users.noreply.github.com> Date: Thu, 1 Jun 2023 18:55:36 +0200 Subject: [PATCH] implement lpoke/lpeek with compound instructions --- cc65/include/memory.h | 3 ++- cc65/src/memory.c | 4 ++-- cc65/src/memory_asm.s | 28 ++++++++++++++++++++++++---- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/cc65/include/memory.h b/cc65/include/memory.h index 80c429c..d43faea 100644 --- a/cc65/include/memory.h +++ b/cc65/include/memory.h @@ -28,10 +28,11 @@ extern struct dmagic_dmalist dmalist; extern unsigned char dma_byte; void mega65_io_enable(void); -unsigned char qpeek(long address); unsigned char lpeek(long address); unsigned char lpeek_debounced(long address); +unsigned char dma_peek(long address); void lpoke(long address, unsigned char value); +void dma_poke(long address, unsigned char value); void lcopy(long source_address, long destination_address, unsigned int count); void lfill(long destination_address, unsigned char value, diff --git a/cc65/src/memory.c b/cc65/src/memory.c index bbc3a91..3c498e1 100644 --- a/cc65/src/memory.c +++ b/cc65/src/memory.c @@ -21,7 +21,7 @@ void do_dma(void) POKE(0xd705U, ((unsigned int)&dmalist) & 0xff); // triggers enhanced DMA } -unsigned char lpeek(long address) +unsigned char dma_peek(long address) { // Read the byte at
in 28-bit address space // XXX - Optimise out repeated setup etc @@ -65,7 +65,7 @@ unsigned char lpeek_debounced(long address) return db1; } -void lpoke(long address, unsigned char value) +void dma_poke(long address, unsigned char value) { dmalist.option_0b = 0x0b; diff --git a/cc65/src/memory_asm.s b/cc65/src/memory_asm.s index 4233267..646dbf7 100644 --- a/cc65/src/memory_asm.s +++ b/cc65/src/memory_asm.s @@ -1,12 +1,32 @@ - .export _qpeek + .export _lpoke, _lpeek - .importzp sreg,tmp1,tmp2,tmp3,tmp4 + .p02 - .p4510 + .importzp sp,sreg,tmp1,tmp2,tmp3,tmp4 + .import incsp4 -.proc _qpeek: near + .p4510 .segment "CODE" + +.proc _lpoke: near + pha + neg + neg + .p02 + lda sp + .p4510 + neg + neg + sta tmp1 + ldz #$00 + pla + nop + sta (tmp1),z + jmp incsp4 +.endproc + +.proc _lpeek: near sta tmp1 stx tmp2 lda sreg