nanochess / IntyBASIC

IntyBASIC compiler for Intellivision (CP1610 processor)
BSD 2-Clause "Simplified" License
35 stars 5 forks source link

POKE #16

Closed artrag closed 5 years ago

artrag commented 5 years ago

I see that POKE $CFFF, $CA5E is translated in MVII #CA5E,R0 MVII #CFFF,R1 MVO@ R0,R1 which is correct, but it is using 3 instructions and 2 registers

Would it possible to replace its translation by this: MVII #$CA5E, R0 MVO R0, $CFFF
that is using 2 opcodes and one register ?

intvnut commented 5 years ago

BTW, this incredibly ugly hack achieves that effect:

ASM _cur EQU $
        ASM ORG $CFFF
pageC:  ASM ;
        ASM ORG $DFFF
pageD:  ASM ;
        ASM ORG $EFFF
pageE:  ASM ;
        ASM ORG $FFFF
pageF:  ASM ;
        ASM ORG _cur

POKE varptr pageC(0), $CFFF
POKE varptr pageD(0), $DFFF
POKE varptr pageE(0), $EFFF
POKE varptr pageF(0), $FFFF

That generates:

;[15]     POKE varptr pageC(0), $CFFF
SRCFILE "/tmp/p.bas",15
MVII #53247,R0
MVO R0,label_PAGEC
;[16]     POKE varptr pageD(0), $DFFF
SRCFILE "/tmp/p.bas",16
MVII #57343,R0
MVO R0,label_PAGED
;[17]     POKE varptr pageE(0), $EFFF
SRCFILE "/tmp/p.bas",17
MVII #61439,R0
MVO R0,label_PAGEE
;[18]     POKE varptr pageF(0), $FFFF
SRCFILE "/tmp/p.bas",18
MVII #65535,R0
MVO R0,label_PAGEF