32k Internal ram with m/c above 32k

Discussions about Sinclair ZX80 and ZX81 Hardware
DereX81
Posts: 7
Joined: Sat Aug 21, 2021 5:11 pm

32k Internal ram with m/c above 32k

Post by DereX81 »

Hi all,

This is my first post to the forum. I have installed 32k of internal ram to one of my ZX81's and would like to place some m/c in the 32-48k area. However the circuit I used has the A15 and /M1, which gives me 16-32k and 48-64k, but following various threads (m1not in particular), I believe it is not possible to run m/c in the 48-64k area (I have tried to run some code at 50,000 but this crashes the '81)

Does anyone have a working circuit that will allow a 32k ram chip (62256) to use the 16-32 and 32-48k area AND m/c in the 32-48k area ?
User avatar
1024MAK
Posts: 5101
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: 32k Internal ram with m/c above 32k

Post by 1024MAK »

In a standard ZX81/TS1000 and similar computers, the ULA uses address line A15 to decide if it should override the data from the data bus with the NOP opcode. As when the system is generating a display, it’s the Z80 that gets the display data. It literally executes the screen data, but before it can actually grab the value from the data bus, the ULA grabs the value and overrides the data with the hex code 0x00. This is a NOP (no operation) instruction. The Z80 reads this NOP instruction, does nothing for this instruction cycle and then starts the instruction fetch for the next memory location.

The display file is not at a fixed location in memory. It can be anywhere between 16K (16384 or 0x4000) and 32K (32767 or 0x7FFF), this results in the ‘shadow’ or ‘echo’ area being between 48K (49153 or 0xC000) and 64K (65535 or 0xFFFF). It is not possible to run machine code in this area unless the circuitry disables the display system. But then it would not be a ZX81!

If you are talking about the modification that uses a resistor and a diode or a couple of NAND gates (such as this circuit) to map RAM to the 48K to 64K area, this area can only be used for data. Including anything you like. If you want to store a machine code program here, to run it, you will need to copy it elsewhere first, then run it from the new location.

Note that if you have RAM between 32K and 48K, the display file can end up in this area if you have a big BASIC program. The display file cannot overlap the 32K boundary.

If you want RAM in the area between 32k (32768 or 0x8000) and 48k (49151 or 0xBFFF) then you need some circuitry to disable the ROM, as due to partial decoding, a ‘shadow’ or ‘echo’ of it normally appears in this area.

As you can see, it’s very complex for what people consider to be a ‘simple’ computer…

As the vast majority of software was (and is) written only for machines with a maximum of 16k bytes or RAM, most owners don’t worry about having more than 16k bytes of RAM.

For more information and how to make better use of RAM, read this article ;-)

The M1NOT topic is here.

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

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
User avatar
mrtinb
Posts: 1906
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: 32k Internal ram with m/c above 32k

Post by mrtinb »

There is a trick, if you are not a beginner in Z80 assembly.

All instructions that start with 0,1,2,3,8,9,A and B will be overridden with a NOP instruction, but all instructions that starts with a 4,5,6,7,C,D,E and F are not modified, so these can be used to programs on any address.

Since you'll be lacking half of the instruction set, you have to be very creative.

The instructions for setting absolute values are not posible, so to instead of

Code: Select all

LD H,55h (26 55)
which is not possible, you can code it like this:

Code: Select all

AND 00h (E2 00)
ADD A,55h (C2 55)
LD H,A (67)
In this example it goes from 2 bytes to 5 bytes.

Like I said, you need to be creative.
Last edited by mrtinb on Mon Aug 23, 2021 2:46 pm, edited 1 time in total.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
DereX81
Posts: 7
Joined: Sat Aug 21, 2021 5:11 pm

Re: 32k Internal ram with m/c above 32k

Post by DereX81 »

Thanks both for your prompt responses

My Z80 m/c programming skills are limited, but growing, so I need to keep the software side as simple as possible
I'm still decimal, so sorry to all the Hexer's

The m/c test i'm using is:

32768 LD BC, 65535 1, 255, 255
32771 RET 201

Then PRINT USR 32768

Of course I'm expecting 65535, but so far in 32-48k range I just get crashes

Today I tested an OR gate for the A14 and A15 address lines connected to the A14 input pin on the ULA, (Yes I had to cut the A14 and A15 tracks to make the mods), so now I have ROMCS below 16k and RAMCS above 16k through the ULA. My 32k internal ram (as per link, but presently without battery backup) now gives me ram from 16-32k and 32-48k (and a shadow of 32-48k between 48-64k), but m/c still won't run in the 32-48k area ?. What else do I need to add, or is it just not possible (from the hardware side) ?

The reason I'm doing this is because I have a working Compact Flash storage interface that allows me to load and save programs within a few seconds, but the OS for the interface needs to run in m/c either at 8-16k or above 32k. I have a couple of Wilf Rigter's 64k internal rams which work fine, but would like to try with 32k ram if possible
gozzo
Posts: 452
Joined: Fri Jul 08, 2011 8:52 pm

Re: 32k Internal ram with m/c above 32k

Post by gozzo »

its possible the mod the zx81 to allow machine code in the 32768 to 49151 area using the M1NOT mod, should be info on the 'net, maybe somewhere here ....i dont think its possible in any cases to run machine code above 49152 as thats where the dfile execution echo is and needs to be..???
DereX81
Posts: 7
Joined: Sat Aug 21, 2021 5:11 pm

Re: 32k Internal ram with m/c above 32k

Post by DereX81 »

Thanks Gozzo,

The m1not circuit seems to be very elusive, I've been scouring the net for more than a month to find something different to this one (A) attached, which doesn't allow me to use M/C between 32-48K with full 64k available. I found this one yesterday from Siggi on a German forum but haven't had time to connect and try it yet, however I have checked the logic in a simulator and they both seem to give the same output on RAM/ROMCS and the internal D flip-flop inside the 2C210 ULA. I can use M/C in 32-48K if I change the ULA to a vLA81, and it kinda works if I disconnect the /m1 line into the 74HC451 based ram/rom controller (Thanks to Wilf Rigter!!), but the results are glitchy to say the least and could end up causing damage to the Zeddy. So if anyone has any other m1not circuits please send them in
Attachments
zx81-m1not-b.jpg
zx81-m1not-a.jpg
zx81-m1not-a.jpg (10.43 KiB) Viewed 2924 times
DereX81
Posts: 7
Joined: Sat Aug 21, 2021 5:11 pm

Re: 32k Internal ram with m/c above 32k

Post by DereX81 »

So I went back to basics and resoldered a new 1N60P Ge diode and 4k7 resistor as the M1not circuit (A) as shown in my previous post and to my delight I was able to run some M/C above 32767 in my battery backed ram circuit (attached). This also worked with Wilf Rigter's 32k barebones ram circuit, slightly modified to map memory from 16 to 48k
zxx81-32k-ram-mc32768.pdf
(164.52 KiB) Downloaded 140 times
Siggi said the M1not circuit should be reversible if you need to run large BASIC programs and could be done by removing one of the diode pins, I tried this without success, but it does work if a 1k resistor is used in place of the 4k7, (once again not sure if this could cause problems if used for long duration?), the better option is to use a SPDT switch (attached)

Hope this may be of use to anyone who wants to add 32k of internal ram
Attachments
m1not-21a.jpg
gozzo
Posts: 452
Joined: Fri Jul 08, 2011 8:52 pm

Re: 32k Internal ram with m/c above 32k

Post by gozzo »

if you fit the m1not circuit, you dont need to 'deactivate' it if you have basic over 32768, it 'should' make no difference
DereX81
Posts: 7
Joined: Sat Aug 21, 2021 5:11 pm

Re: 32k Internal ram with m/c above 32k

Post by DereX81 »

Thanks Gozzo,

To be honest I’m not planning to write any code that big. I have only been able to get >16k programs to work on the ‘eighty one’ emulator on my pc, when I’ve typed in on a real zx81 they all crash, m1not or not?, probably because of the d-file straddling the 32k boundary, I’ve not tried loading in a large program yet
User avatar
siggi
Posts: 988
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: 32k Internal ram with m/c above 32k

Post by siggi »

gozzo wrote: Thu Sep 16, 2021 11:14 pm if you fit the m1not circuit, you dont need to 'deactivate' it if you have basic over 32768, it 'should' make no difference
If a BASIC program is bigger than 16K, the D-file is located above 32K (above the BASIC program). It an M1!-circuit is active, the D-file is executed as code (during dispaly) as all other m/c, resulting usually in a crash ...

Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
Post Reply