Autor
| RLD and RRD Z80 commands - any usage?
|
Prodatron msx master Mensajes: 1113 | Publicado: Mayo 22 2007, 01:59   |
Yesterday someone in a CPC board posted this question, and as..
1.) I never used these Z80 commands before
2.) I couldn't find infos in this MSX board via the search function
..I would be quite interested in the question, if anybody has found a good use for RLD & RRD?
|
|
flyguille msx master Mensajes: 1237 | Publicado: Mayo 22 2007, 02:04   |
RLD / RRD? you mean the rotating bit?
it is not?
RL D
RR D
what you mean exactly about usague?
(I not understand the question because they are very common)
|
|
Alcoholics_Anonymous msx friend Mensajes: 10 | Publicado: Mayo 22 2007, 04:50   |
I guess you mean besides their intended usage in multiplication and division of BCD numbers?
I've seen it used to scroll screens by 4 pixels in some Spectrum games, but that's about it. And I've never used them either.
|
|
flyguille msx master Mensajes: 1237 | Publicado: Mayo 22 2007, 05:54   |
Quote:
| Yesterday someone in a CPC board posted this question, and as..
1.) I never used these Z80 commands before
2.) I couldn't find infos in this MSX board via the search function
..I would be quite interested in the question, if anybody has found a good use for RLD & RRD?
|
WOW!, sincerely I always though that was clones of RR D / RL D..... I re-checked the Z80 doc, now I see your point......
Aplications:
Thinks, In a ROM and by that an UNCRACKEABLE GAME!
just use RRD / RLD in everywhere you need to load the lower nibble of a RAM address.... If the program runs in RAM, it will work one time, the second time the RAM will be modified and IT will not work!.
By example, some graphics load in screen 5. The second time that they will be loaded to VRAM, all graphics corrupted by sure.!
But, without doubt the original task is the load of BCD digits.!
|
|
NYYRIKKI msx master Mensajes: 1533 | Publicado: Mayo 22 2007, 11:22   |
Here is for example compact HEX print routine, that uses RLD: (Data to be printed is pointed by HL)
xor a
rld
call Nibble
Nibble push af
daa
add a,F0h
adc a,40h
call a2h ;CHPUT
pop af
rld
ret
|
|
flyguille msx master Mensajes: 1237 | Publicado: Mayo 22 2007, 19:19   |
Quote:
| Here is for example compact HEX print routine, that uses RLD: (Data to be printed is pointed by HL)
xor a
rld
call Nibble
Nibble push af
daa
add a,F0h
adc a,40h
call a2h ;CHPUT
pop af
rld
ret
|
Very good... I rember the "daa + add a,F0h" trick from GuyverR800's code... |
|
msd msx professional Mensajes: 625 | Publicado: Mayo 22 2007, 19:32   |
Hey that was my code
|
|
SapphiRe msx user Mensajes: 33 | Publicado: Mayo 22 2007, 20:49   |
You can also use RRD or RLD to access to the nibbles of a table in RAM. I use one of these instructions to apply changes in an SC2 color table decrunched to RAM before transfer it to VRAM.
|
|
flyguille msx master Mensajes: 1237 | Publicado: Mayo 23 2007, 01:20   |
Quote:
| Hey that was my code
|
Oh,! Sorry O.o) |
|
Prodatron msx master Mensajes: 1113 | Publicado: Mayo 23 2007, 12:02   |
Really impressive.
So this code
or a
daa
add a,F0h
adc a,40h
will convert 0-15 (in A) into "0"-"9" and "A"-"F"...
Really cool, I never had a deeper look at the DAA command!
|
|
pitpan msx master Mensajes: 1418 | Publicado: Mayo 23 2007, 18:21   |
I totally miss these instructions! I think that some of my programs would include them very soon  |
|
msd msx professional Mensajes: 625 | Publicado: Mayo 23 2007, 21:26   |
|
|
glaurungattack msx novice Mensajes: 18 | Publicado: Mayo 26 2007, 13:20   |
Quote:
| Thinks, In a ROM and by that an UNCRACKEABLE GAME!
just use RRD / RLD in everywhere you need to load the lower nibble of a RAM address.... If the program runs in RAM, it will work one time, the second time the RAM will be modified and IT will not work!.
|
In fact there is one rom that does it: Ashguine 3 (from Microcabin). It was a hard time to find what was going wrong with the disk version  Anyway, I don't think they did that for protection purposes, but just for coding convenience. |
|
|
|
|