So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

For experts to discuss very technical stuff and newbies to ask why the Spectrum they bought off ebay doesn't work.
User avatar
1bvl109
Dizzy
Posts: 98
Joined: Tue Jun 04, 2019 9:00 pm

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by 1bvl109 »

Ast A. Moore wrote: Sat Apr 25, 2020 7:01 pm If you can get by without using index registers, then don’t worry about them. You’ll figure out why you need them when you need them.
But aren't they still just a sad substitute for a zero page like in say the 6800? This cat has to much mustard.
"Truth would quickly cease to be stranger than fiction, once we got used to it." - H.L. Mencken
User avatar
Lethargeek
Manic Miner
Posts: 743
Joined: Wed Dec 11, 2019 6:47 am

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by Lethargeek »

1bvl109 wrote: Sat Apr 25, 2020 7:18 pm substitute for a zero page
except it's not just for one page :P
catmeows
Manic Miner
Posts: 718
Joined: Tue May 28, 2019 12:02 pm
Location: Prague

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by catmeows »

Firefox wrote: Fri Apr 24, 2020 5:50 pm
Ralf wrote: Fri Apr 24, 2020 5:39 pm I'd really like if CPU stored these addresses for RETs somewhere "in another dimension" and not messed with MY stack :)
You might enjoy the 6809, then. :)
Best 8-bit design ever.
Proud owner of Didaktik M
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by Ast A. Moore »

1bvl109 wrote: Sat Apr 25, 2020 7:18 pm But aren't they still just a sad substitute for a zero page like in say the 6800? This cat has to much mustard.
No. The Z80 is a more advanced architecture. It doesn’t need a zero page, because it has a plethora of registers to work with. Regardless, the 6800 did have an actual index register.
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
User avatar
1bvl109
Dizzy
Posts: 98
Joined: Tue Jun 04, 2019 9:00 pm

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by 1bvl109 »

Lethargeek wrote: Sat Apr 25, 2020 8:02 pm except it's not just for one page :P
I'm willing to compromise. Of course the Z80 designer can not be held responsible for Sir Clive's decision, to offer no hardware sprites. In connection with memory mapped hardware which needs more than one address, the (IX+n) stuff actually seems convenient. On the other hand, they already decided, that the memory preferably should be pristine, by offering the IORQ to connect to hardware. Also compatibility to the 8085 is already so so, as there is no https://www.geeksforgeeks.org/serial-i- ... processor/

Anyway I'm puzzled that programmers of sprites for the Spectrum seem to think in terms of "we'll do an emulation of hardware sprites" which seems to be an unnecessary restriction on a machine with little resources to waste. I wonder what the usage of HL etc vs. IX/IY say in the ROMs is.
"Truth would quickly cease to be stranger than fiction, once we got used to it." - H.L. Mencken
User avatar
Lethargeek
Manic Miner
Posts: 743
Joined: Wed Dec 11, 2019 6:47 am

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by Lethargeek »

1bvl109 wrote: Sun Apr 26, 2020 6:24 pm Anyway I'm puzzled that programmers of sprites for the Spectrum seem to think in terms of "we'll do an emulation of hardware sprites"
not hardware sprites but rather object descriptors (likely including the sprite data)
1bvl109 wrote: Sun Apr 26, 2020 6:24 pm I wonder what the usage of HL etc vs. IX/IY say in the ROMs is.
IY is used to access system variables (and due to a bug, it needs to point at them all the time if the interrupt mode 1 is allowed)
IX has no dedicated role and is used in the beeper and tape routines only iirc just like HL

Anyway, because the memory access with these registers is rather slow, it is used usually for rarely accessed data when it's even slower to save and restore other registers being already in use at the moment. Same about the usual register ops, as these two are just a slower version of HL.
User avatar
1024MAK
Bugaboo
Posts: 3123
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by 1024MAK »

1bvl109 wrote: Sun Apr 26, 2020 6:24 pm On the other hand, they already decided, that the memory preferably should be pristine, by offering the IORQ to connect to hardware. Also compatibility to the 8085 is already so so, as there is no https://www.geeksforgeeks.org/serial-i- ... processor/
System designers can use memory mapped I/O on a Z80 system if they wish. Some ZX81 expansions used I/O that was memory mapped. And some Z80 systems did use memory mapped I/O. Further, you could make the case that the ZX Spectrum screen RAM is memory mapped I/O....

The Z80 had already been designed when Intel launched it’s 8085. The Z80 was designed so it can run 8080 code. As it happens, the 8085 was designed to also run 8080 code. Only the SIM and RIM instructions were new to the 8085. So any 8085 code that only uses 8080 instructions will run on a Z80 (although there are minor timing differences between 8080 and 8085 with some instructions).

If you want pain with a stack, use a 8 bit Microchip PIC microcontroller (fixed hardware stack), or a 6502 where the stack is stuck in page 1.
At least with the Z80 you can have the stack anywhere you like in memory. And it is possible to have more than one stack in memory if you are careful with your code (but only one active at a time).

Also keep in mind that the Z80, 6502, 6800, 6802 etc were all designed for embedded systems and not for general purpose computers, let alone for games machines.

If you want a CPU with lots of fancy and flexible instructions, use a 680xx. E.g, a Sinclair QL :mrgreen:

Mark
:!: Standby alert :!:
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :dance
Looking forward to summer later in the year.
User avatar
1bvl109
Dizzy
Posts: 98
Joined: Tue Jun 04, 2019 9:00 pm

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by 1bvl109 »

Seven.FFF wrote: Sat Apr 25, 2020 1:51 pm Except that the PC by convention moves forwards too!
Could as well go the other way too. Apart from the fact, that the PC is usually not a register used to manipulate what is there. There darn well should already be something sensible there.
Seven.FFF wrote: Sat Apr 25, 2020 1:51 pmThe design isn’t inherently dangerous. My code detects when it overlaps.
Meanwhile in other semantics: The design is inherently dangerous, unless there is code, which detects when it overlaps. But there also could have been hardware for the purpose. LSPC nn, load stack pointer control register, an interrupt to $40 is triggered, if the SP goes below nn.
Seven.FFF wrote: Sat Apr 25, 2020 1:51 pmIt’s always up to the program designer to make their code safe, ...
Depends. In BASIC, using an out of bound index, you expect your interpreter to tell you. In C you expect .... everything.
Seven.FFF wrote: Sat Apr 25, 2020 1:51 pmDid you ever see code which checked the stack pointer against a lower boundary before every push?
Of course not. If at all, we all do it the Speccy-ROM way, but that is because we are all sinners,
"Truth would quickly cease to be stranger than fiction, once we got used to it." - H.L. Mencken
User avatar
1bvl109
Dizzy
Posts: 98
Joined: Tue Jun 04, 2019 9:00 pm

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by 1bvl109 »

1024MAK wrote: Mon Apr 27, 2020 10:00 amSystem designers can use memory mapped I/O on a Z80 system if they wish.
I would be hard pressed how a CPU using memory could deny this.
1024MAK wrote: Mon Apr 27, 2020 10:00 amSome ZX81 expansions used I/O that was memory mapped.
There was plenty of room though. Who needs a shadow ROM? Wait a minute. OUT on a ZX81? Wasn't the screen crashing down on you?
1024MAK wrote: Mon Apr 27, 2020 10:00 amFurther, you could make the case that the ZX Spectrum screen RAM is memory mapped I/O....
Sure. Not the fault of the Z80 designers though.
1024MAK wrote: Mon Apr 27, 2020 10:00 am The Z80 had already been designed when Intel launched it’s 8085.
Thanks, I had no clue.
1024MAK wrote: Mon Apr 27, 2020 10:00 am If you want a CPU with lots of fancy and flexible instructions, use a 680xx. E.g, a Sinclair QL :mrgreen:
Calmly, calmly .. I'll shoot myself in this foot next time.
"Truth would quickly cease to be stranger than fiction, once we got used to it." - H.L. Mencken
akeley
Dynamite Dan
Posts: 1048
Joined: Sat Feb 01, 2020 5:47 pm

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by akeley »

I find coders arguing quite an amusing thing to watch, that's because I've always sort of imagined (being a complete ignoramus in this field) that there shouldn't be any room for manuever. It seems such a scientifically strict area after all. Most other internet bickerings are about opinions, so anybody can say pretty much anything and get away with it, but this is like, maths, innit? ;)
User avatar
1024MAK
Bugaboo
Posts: 3123
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by 1024MAK »

1bvl109 wrote: Thu Apr 30, 2020 8:21 pm Wait a minute. OUT on a ZX81? Wasn't the screen crashing down on you?
Although ZX81 does not have OUT or IN in it’s BASIC, the relevant Z80 machine code instructions work fine without crashing the screen, as long as you don’t do something silly. As on the ZX Spectrum, Sinclair only used minimal decoding.

Mark
:!: Standby alert :!:
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :dance
Looking forward to summer later in the year.
User avatar
1024MAK
Bugaboo
Posts: 3123
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by 1024MAK »

akeley wrote: Thu Apr 30, 2020 9:10 pm I find coders arguing quite an amusing thing to watch, that's because I've always sort of imagined (being a complete ignoramus in this field) that there shouldn't be any room for manuever. It seems such a scientifically strict area after all. Most other internet bickerings are about opinions, so anybody can say pretty much anything and get away with it, but this is like, maths, innit? ;)
To continue, please pay the £1 charge... :mrgreen:

Mark
:!: Standby alert :!:
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :dance
Looking forward to summer later in the year.
User avatar
Joefish
Rick Dangerous
Posts: 2059
Joined: Tue Nov 14, 2017 10:26 am

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by Joefish »

akeley wrote: Thu Apr 30, 2020 9:10 pm I find coders arguing quite an amusing thing to watch, that's because I've always sort of imagined (being a complete ignoramus in this field) that there shouldn't be any room for manuever. It seems such a scientifically strict area after all. Most other internet bickerings are about opinions, so anybody can say pretty much anything and get away with it, but this is like, maths, innit? ;)
There's plenty of room to learn!

Programming is like LEGO - there are all these fixed-sized pieces that at first glance appear to only do one thing. But get a handful together and do a few sums and you quickly discover you've got a billion different possible combinations and it's up to you to pick what you think is the best one. Chances are someone else may not make exactly the same choice given that many options!

And maybe you figure it out on your own, or someone tells you, that the best way to build a LEGO house is to sort out the roof first, since it's the most complex shape, then plan the layout of the house to fit under it. And you start building way better houses with roofs with all sorts of angles and dormer windows that all seem to fit perfectly that you never managed before.

Then someone shows you how, with the odd hinge or bracket here and there, you can fit those same pieces you've always been using sideways or upside-down and you've suddenly shifted onto a whole new way of putting things together and making shapes you never even thought of before.

And before you know it, you've solved a problem by writing a program that runs backwards and then you can't find anyone else who understands how it even works.
Spoiler
The trick is to ignore the people who tell you what you can't do. Or at least, don't take them seriously.
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by Ast A. Moore »

Joefish wrote: Fri May 01, 2020 11:45 am you've solved a problem by writing a program that runs backwards and then you can't find anyone else who understands how it even works.
And that anyone often includes you. ;)
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
User avatar
Morkin
Bugaboo
Posts: 3277
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by Morkin »

At the risk of getting splinters in my ar$e from the fence I'm currently sitting on... :lol: ...

...When I wrote Catacombs I was learning assembly, and didn't use the IX or IY registers at all. So overall, yep - you don't need to use them if you don't want to.

...Well, actually - IX appears a couple of times in the redefine keys routine, but that's 'cos I copied & pasted (read: stole) that routine wholesale from [mention]R-Tape[/mention] so I'm not counting those... :oops:

For the sequel I'd learned about IX and I had to keep track of more objects, sprites etc. and wasn't too worried about speed, so I used IX+n a fair bit for the reasons already suggested. Though I think it's probably the only time I've actively made a change for the sake of making my code more structured... :D

What I like about assembly is because it tends to be a one-person-development, readability and structure is up to you, and it's fine to do crazy things if you want as long as the end result is what you intended. Like that Snake game that only used the LD instruction. :)
akeley wrote: Thu Apr 30, 2020 9:10 pmbut this is like, maths, innit? ;)
Sure, but all you need to know is your 2x table... :P
My Speccy site: thirdharmoniser.com
User avatar
1bvl109
Dizzy
Posts: 98
Joined: Tue Jun 04, 2019 9:00 pm

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by 1bvl109 »

1024MAK wrote: Thu Apr 30, 2020 10:53 pm ... the relevant Z80 machine code instructions work fine without crashing the screen, as long as you don’t do something silly.
I think, I had this in mind
ZX80/ZX81 I/O Ports

Output to Port FFh (or ANY other port)
Writing any data to any port terminates the Vertical Retrace period, and restarts the LINECNTR counter. The retrace signal is also output to the cassette (ie. the Cassette Output becomes High).
https://problemkaputt.de/zxdocs.htm#zx80zx81iomap
"Truth would quickly cease to be stranger than fiction, once we got used to it." - H.L. Mencken
User avatar
1bvl109
Dizzy
Posts: 98
Joined: Tue Jun 04, 2019 9:00 pm

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by 1bvl109 »

akeley wrote: Thu Apr 30, 2020 9:10 pm I find coders arguing quite an amusing thing to watch, that's because I've always sort of imagined (being a complete ignoramus in this field) that there shouldn't be any room for manuever.
Well sure, we only need a couple of Next or other hardware emulation, where we can run different CPU-designs an say some 100+ programmers willing to optimize their games on both and than we''ll see. Be warned, that I'm prepared to call everyone chicken, who doesn't shell out the money to prove me wrong. I want justice! https://www.oglaf.com/justice/
akeley wrote: Thu Apr 30, 2020 9:10 pm ... but this is like, maths, innit? ;)
Math is math though. Maybe there you'll find guaranteed correctitude and tranquillity of mind, traveler. Simply never ever mention Banach-Tarski or a couple of other things and it's unlikely that the big knives come out.
"Truth would quickly cease to be stranger than fiction, once we got used to it." - H.L. Mencken
User avatar
1bvl109
Dizzy
Posts: 98
Joined: Tue Jun 04, 2019 9:00 pm

Re: So the Z80 is an improved 8080/8085, but what about LD A,(MN)?

Post by 1bvl109 »

Lethargeek wrote: Sun Apr 26, 2020 11:41 pm not hardware sprites but rather object descriptors (likely including the sprite data)
OOP-Think in assembler than.
Lethargeek wrote: Sun Apr 26, 2020 11:41 pm IY is used to access system variables (and due to a bug, it needs to point at them all the time if the interrupt mode 1 is allowed)
This I admit is some reasonable use, so that you can have one byte magic numbers instead of two byte addresses.
Lethargeek wrote: Sun Apr 26, 2020 11:41 pm Same about the usual register ops, as these two are just a slower version of HL.
I'm not quite sure, that you mean here by "usual register ops". BC and DE as compared to HL? LD A,(...) all have seven clock cycles.
"Truth would quickly cease to be stranger than fiction, once we got used to it." - H.L. Mencken
Post Reply