Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I can't read the LY register of the gameboy

Recently I started learning how can I create games for gameboy in z80 asm, I know that there is a register in the memory ($ff44) the LY register, I tried to read that register using the instruction "ld a, ($ff44)" in hexadecimal "3a 44 ff" but when I run the game in the gameboy emulator it close the game.

If I use the intructions:
"ld hl, $ff44
ld a, (hl)", I think that it works, but why it doesn’t work when I use the other instruction?

(I’m sorry, I don’t speak english, so this text may be bad wrote.)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The GameBoy processors is not a z80. It’s also not an Intel 8080. It has strong similarities with both of those, of course.

The 3A opcode does not mean ld a, (nn) on the GameBoy z80-like processor, it means ld a, (hl-) also denoted ldd a, (hl), however you write it it’s an instruction that uses the address from hl and then decrements hl, it doesn’t take two extra code bytes as address. The 44 and FF would be seen as extra instructions, with the FF meaning rst 7.

The GameBoy processors has something else (which the z80 doesn’t have) that you may be able to use: ld a, (0xFF00 + n) encoded as F0 n.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading