sam coupe. cant poke memory address 57366

Anything relating to non Sinclair computers from the 1980's, 90's or even before.
Post Reply
User avatar
777
Manic Miner
Posts: 523
Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk

sam coupe. cant poke memory address 57366

Post by 777 »

ive managed to change it in the debugger which works but i cant change it with a poke from basic. i edited to config file to allow rom writes, to see if this made any difference but it doesnt. what is going on here? i also embedded it in the program so it pokes it all the time.
i started programming the spectrum when i was 8 :-

1 plot rnd*255,rnd*175
2 goto 1

http://zxspeccy.great-site.net/
User avatar
Stefan
Manic Miner
Posts: 823
Joined: Mon Nov 13, 2017 9:51 pm
Location: Belgium
Contact:

Re: sam coupe. cant poke memory address 57366

Post by Stefan »

A quick sanity check:

Code: Select all

for f=0 to 1:
poke 57366,f:
print peek 57366:
next f
Which will work just fine.

When using the SAM Coupe you need to be aware of the memory paging scheme. It consists of two 32K blocks. All pages are 16K, you can indicate which page should sit in a block. The lower block using the low memory page register (LMPR) and the upper block using the high memory page register (HMPR).
When using SAM Basic, bank A contains the ROM, bank B contains RAM page ( :dance ) 0, bank C and D contain whatever is needed.

The normal visualization is:

A 0x0000 - 0x3fff (0 - 16383) | ROM 0
B 0x4000 - 0x7fff (16384 - 32767) | page 0
C 0x8000 - 0xbfff (32768 - 49151) | page 1
D 0xc000 - 0xffff (49152 - 65535) | page 2

page A can be replaced by ROM 0, page D can be replaced by ROM 1.

SAM basic provides the 512K of RAM in a virtual address space.
SAM basic address 32768, refers to page 1, offset 0.
SAM basic address 57366, refers to page 2, offset 8214 (57366 modulo 16384)

When using the debugger you need to pay attention to what the value is of HMPR!
User avatar
777
Manic Miner
Posts: 523
Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk

Re: sam coupe. cant poke memory address 57366

Post by 777 »

Stefan wrote: Thu May 25, 2023 4:02 pm

When using the debugger you need to pay attention to what the value is of HMPR!
the hmpr register is 1e. ive tried poking to 548886 but its out of range. how do i access page 30 from basic?
i started programming the spectrum when i was 8 :-

1 plot rnd*255,rnd*175
2 goto 1

http://zxspeccy.great-site.net/
User avatar
Seven.FFF
Manic Miner
Posts: 748
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: sam coupe. cant poke memory address 57366

Post by Seven.FFF »

777 wrote: Thu May 25, 2023 4:11 pm the hmpr register is 1e. ive tried poking to 548886 but its out of range. how do i access page 30 from basic?
The Z80 only has a 16bit address bus, so all addresses in BASIC and machine code are between 0..65535. That's why paging is needed, so smaller slices of the overall RAM and ROM can be swapped in and out of that 64KB CPU address space.

If your HMPR is 30 then bank 30 is in page C (CPU/BASIC address 32768 - 49151) and bank 31 is in page D (CPU/BASIC address 49152 - 65535).

If you wanted to access bank 29, it's not at any address unless your change HMPR or LMPR to 28 or 29. It still exists, and the data stored there is not lost, but it's not positioned behind the little fixed-size windows that a 16 bit address space limits you to.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
User avatar
777
Manic Miner
Posts: 523
Joined: Fri Jun 26, 2020 11:23 am
Location: sw uk

Re: sam coupe. cant poke memory address 57366

Post by 777 »

its ok i managed to get it to work at address 532502
i started programming the spectrum when i was 8 :-

1 plot rnd*255,rnd*175
2 goto 1

http://zxspeccy.great-site.net/
User avatar
Seven.FFF
Manic Miner
Posts: 748
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: sam coupe. cant poke memory address 57366

Post by Seven.FFF »

You're quite right, I apologize. SAM BASIC allows addresses between 0..524,287 (512KB) for POKE, and 0..540,672 (528K) for PEEK, CALL, USR, USR$, etc. It does internal math and paging to magically make it seem as if the CPU has larger than 64KB address space. Very cool!

548,886 is indeed out of range for that, but 532,502 is in range.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
Post Reply