Quick hardware check with Peek

Post Reply
User avatar
RS232
Posts: 90
Joined: Fri Apr 05, 2019 8:57 pm

Quick hardware check with Peek

Post by RS232 »

Trying out some quick memory checks on a recent purchase. Curious if this works on other peoples machines as a fast way of knowing if your machine is what it should be?.. I came across this snippet a long time ago so just checking :D

Print peek 23733

Result
255. 48k
128. 16k
127. Only 16k available on 48k

Print Peek 23732+256*Peek 23733

32767 Correct for 16k but a lower number may indicate memory fault
65535 Correct for 48k

print ((Peek 23730+256*(Peek 23731))-(peek 23653+256*(Peek 23654)); " Memory left"
User avatar
1024MAK
Posts: 5526
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: Quick hardware check with Peek

Post by 1024MAK »

PRINT PEEK 23732 + PEEK 23733 * 256 returns the address of the top of available memory available to BASIC by using a system variable. The BASIC ROM does a test to discover how much RAM is available.

PEEK 23733 returns the most significant 8 bits of the address (address lines A8 to A15).

In both cases, the result is only valid if a program has not changed these system variable values. So best to test immediately after reset or power on.
RS232 wrote: Mon Jun 17, 2024 10:12 am Print peek 23733

Result

128. 16k
127. Only 16k available on 48k
As stated, these are misleading. The system will normally return 127 or a random value greater than 127 if the ‘upper’ RAM is faulty. Or it will not get beyond the ‘copyright screen without crashing or freezing. If 127 is returned, it is not possible to tell if it is a 16K machine or a machine with more RAM, but where the ‘upper’ RAM is faulty.

Print peek 23733

Result
255. 48K of RAM detected. Likely a 48K or 128K machine.
127. 16K of RAM detected. Likely a 16K machine or a machine with more RAM, but where this RAM is faulty.

127*256+255=32767 plus address zero gives 32K or memory, 16K of ROM and 16K of RAM.
255*256+255=65535 plus address zero gives 64K or memory, 16K of ROM and 48K of RAM.

In all cases, this does not mean that all detected RAM is fully functional. The test performed by the BASIC ROM is not designed to fully test or detect faulty RAM. And it does not take into account any bank switched RAM, such as that available in the 128K machines.
RS232 wrote: Mon Jun 17, 2024 10:12 am Print Peek 23732+256*Peek 23733

32767 Correct for 16k but a lower number may indicate memory fault
32767 is correct for a 16K machine. Any result that gives a different value other than 32767 or 65535 indicates a RAM fault. And a result of 32767 on anything other than a 16K machine also indicates a RAM fault.

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Spring approaching...
User avatar
RS232
Posts: 90
Joined: Fri Apr 05, 2019 8:57 pm

Re: Quick hardware check with Peek

Post by RS232 »

Many kind thanks. Their isn't a "pass this man a beer he deserves one" icon available in the smiles list.. but you get my point you deserve one 8-)
Post Reply