CMM2: Suggestion to replace Peek(ProgMem, of) and Peek(VarTbl, of)


Author Message
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4302
Posted: 12:13pm 18 Oct 2021      

Hi Peter,

I recognise that PEEK(ProgMem, offset) and PEEK(VarTbl, offset) only have very specialised use-cases but even within those I'm not sure these are the optimal functions to have in the language because they force the user to read a byte at a time.

Should you consider replacing them with PEEK(ProgMemAddr) and PEEK(VarTblAddr) ? That way MEMORY COPY and MEMORY SET can be used with these data structures, and also PEEK(SHORT|WORD|INTEGER) ... though the user has to be careful to avoid data alignment errors ...

... or is this deliberate to prevent the use poking into these areas ... in which case why is there a POKE(VarTbl ...) ?

Best wishes,

Tom

matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10246
Posted: 03:17pm 18 Oct 2021      

In both cases there are reasons you may wish to read a byte that isn't word aligned so I don't intend to change this. You can do something completely different in the Linux port as this is of minority interest

thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4302
Posted: 03:35pm 18 Oct 2021      

Thanks Peter,

  matherp said  In both cases there are reasons you may wish to read a byte that isn't word aligned


My suggestion wouldn't preclude that, e.g.
Peek(Byte Peek(VarTblAddr) + offset)


though you could argue for:
Peek(Byte Mm.Info(VarTblAddr) + offset)


  matherp said  so I don't intend to change this. You can do something completely different in the Linux port as this is of minority interest


Fair enough, I probably won't as I don't envision much call for extensions beyond the capabilities of the CMM2 and PicoMite that aren't specifically related to interacting with a "real" operating-system.

Best wishes,

Tom