Hi !
"CLAUDIO MASSAO KAWATA" <[EMAIL PROTECTED]> asked:
> Third (the first really MSX related topic): does anybody know
> how the Z80's "R" register works? It controls the "REFRESH" sign
> of the CPU, but when is it generated? When it counts "zero"? It
> wouldn't be very smart, 'cause the register can be set by soft...
> So...?
I would call it the other way round - the refresh controls the R
register.
The Z80 uses a transparent method of memory refresh, where refresh
cycles are mixed in between memory read/write operations (opposed to
burst refresh, where there is only read/write, and every once in a
while the entire memory gets refreshed at once).
Refresh cycles occur at the end of M1 (Machine Cycle 1, or fetching
the 1st byte of an instruction), and the R register is increased with
1 each time.
Only the lower 7 bits of the R register are counting though (DRAM's
used at the time of the Z80's design didn't need more).
The highest bit doesn't count, but can be normally read/written to
using LD A,R & LD R,A instructions.
If you set this bit to some value, this setting will even survive a
software reset of the MSX! (I'm not sure about hardware reset).
After power-on this bit usually (always?) reads 0.
Forcing the R register to some value can indeed screw up memory
refresh, but not in all cases:
-Because R keeps counting, you have to keep setting it, quickly
-Some machines use the refresh signal, but not the refresh address
(contents of R) that is put on the Z80's address pins.
Hint: someone suggested a piece of code to show this. Try this on a
Sony HB-F700 for instance, and I predict it won't do anything on that
machine...
-If the memory is Static RAM it won't do anything
-Emulators will emulate Static RAM ofcourse ;-))
The R register is a good source for A random number (7, not 8 bits!),
but only if used once, or at 'random times'. For instance as a start
value for a random number generator, but NOT for getting a row of
random numbers.
If you use this in a limited size instruction loop, there will be
regular numbers of instructions, and thus regular numbers of
R-increases in every pass through this loop, and the numbers won't be
really random as a result.
There are some good docs online describing this behaviour, if you're
interested, I suggest you check out some of Sean Young's stuff at:
http://www.msxnet.org/tech/Z80/
Greetings,
Alwin Henseler ([EMAIL PROTECTED])
http://huizen.dds.nl/~alwinh/msx MSX Tech Doc page
http://huizen.dds.nl/~alwinh/for_sale
anyone in the Netherlands still needs a 486 mainboard? (sorry ;-)
****
MSX Mailinglist. To unsubscribe, send an email to [EMAIL PROTECTED] and put
in the body (not subject) "unsubscribe msx [EMAIL PROTECTED]" (without the
quotes :-) Problems? contact [EMAIL PROTECTED] (www.stack.nl/~wiebe/mailinglist/)
****