Z-80 code question about a loop that depends on the contents of the refresh register
allison
ajp166 at verizon.net
Wed Dec 14 15:26:12 CST 2016
On 12/14/16 11:33 AM, Ethan Dicks wrote:
> On Wed, Dec 14, 2016 at 2:08 AM, Alexis Kotlowy
> <thrashbarg at kaput.homeunix.org> wrote:
>> On 14/12/2016 09:19, Ethan Dicks wrote:
>>> So far, this loop hangs on all three emulators I've tried - simh's
>>> altairz80, simcpm010 for AmigaDOS, and EMUZ80 for Raspberry Pi. I'm
>>> guessing none of these environments emulate specific behavior of the
>>> Refresh register?
>>>
>> Ethan,
>>
>> Have you tried running it on ZEMU?
> I have not. Thanks for the suggestion. I don't know which emulators
> might implement the refresh register.
>
>> (Windows only unfortunately, but should run under WINE).
> That's what it will take - I'm 100% UNIX/Linux (well... plus VAX and
> PDP-11 and Amiga and PET...)
>
>> http://www.z80.info/z80emu.htm#EMU_CPU_W32
>>
>> I tried single stepping through it just now and it looks like it's doing
>> its job, at least as a possible random number generator.
> Excellent. I expect it should work.
>
>> When was this game written? Perhaps it's supposed to lock up on
>> emulators that don't emulate the Z80 completely?
> 1979. Emulators weren't a factor then.
>
>> Not knowing what the game is, it could be a copy protection routine too.
> I don't think so. It's just generating a percentage which it's using
> for probability.
>
>> I can't find any information on what the MSB is set to when the
>> accumulator is loaded with R, and what the Sign flag is set to. The
>> datasheet says the Sign and Zero flags are changed by the instruction.
>> If either of these flags are set, the routine enters an infinite loop.
> Tony Duell pointed that out too. I suspect that this code works for
> machines that existed at the time, with 16K DRAMs, and might or might
> not have worked on later machines. A quick scan of InfoWorld links
> and such and I can't find any S-100 cards with 4164s older than about
> 1983. I don't think there were many commercially available 64K DRAMs
> prior to 1982.
>
> -ethan
>
The first year of appearance for 64K DRAMS was mid to late 1980
(expensive and scarce)
and mostly sampling to the big vendors. For regular users late 81 when
the price
started down. There were three flavors, 8bit refresh, 7bit refresh, and
internal refresh came in a bit later by maybe mid 1982.
Adoption was a bit slow due to cost and Alpha particle concerns with
soft errors
The Z80 could do 8bit refresh with hardware or software or the self
refresh (internal).
Nominally the R register is a counter that increments from any value to
7bit overflow.
I believe most emulators actually do that. Check MyZ80 Simon Crans work
(32bit
dos/ pre-7-winders only or in a 32bit sim/VM).
Either that or lookup and assemble Grant Searle's low chip count Z80 system.
Allison
More information about the cctalk
mailing list