picocomputer/ehbasic-plus

XREG / XPEEK / XPOKE / XDEEK / XDOKE

Opened this issue · 2 comments

Support for extended memory makes graphics and sound programming more approachable from BASIC.
XREG dev, chan, addr, data0, ...
data = XPEEK(addr)
XPOKE addr, data

See related ram-memory-peek and xram-peek efforts in @jthwho's RP6502-Shell, and his two c-functions:

void ram_reader(uint8_t *buf, uint16_t addr, uint16_t size) {
    uint8_t *data = (uint8_t *)addr;
    for(; size; size--) *buf++ = *data++;
    return;
}

void xram_reader(uint8_t *buf, uint16_t addr, uint16_t size) {
    RIA.step0 = 1;
    RIA.addr0 = addr;
    for(; size; size--) *buf++ = RIA.rw0;
    return;
}

Approach, do in a separate git-branch:

Model XPOKE/XPEEK from existing PEEK/POKE code:

  1. Add new XPOKE/XPEEK commands to token-system; do XPEEK 1st:
    a. POKE (and DOKE) is a "primary command token" type.
    b. PEEK (and DEEK) is a "functions token" type; "functions tokens" require an extra "pre process routine table" entry.
    c. TAB_ASCX: and LBB_xxx: table entries needed for the two new "X" commands patterned after PEEK and POKE.
  2. Implement the execution-code LAB_XPOKE and LAB_XPEEK patterned from POKE/PEEK needed to access pico's xram.
  3. Repeat above for XDOKE and XDEEK - for double-bytes (16-bit versions).
  4. Code XREG last, learning from above.