Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,435,322
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 04-19-24 09:31 AM
Guest: Register | Login

0 users currently in ROM Hacking | 1 guest

Main - ROM Hacking - Z80 Question New thread | New reply


Xeon
Posted on 03-11-07 01:53 PM (rev. 3 of 03-11-07 01:54 PM) Link | Quote | ID: 13810


Red Paratroopa
Level: 31

Posts: 14/174
EXP: 181471
Next: 3892

Since: 03-09-07

Last post: 6013 days
Last view: 3215 days
Why would you need to load a byte pointer onto the A register, and then load a onto another register. Why can't you just load the pointer directly onto the register your trying to use.

Ex:
ld a, [mapdataptr1_D36A]
ld e, a

Why can't you just do

ld e, [mapdataptr1_D36A]

Or is there some reason you can't do that? I'm just now learning Z80 assembly so some of this is just confusing.

MathOnNapkins
Posted on 03-11-07 04:55 PM Link | Quote | ID: 13857


Super Koopa
Level: 62

Posts: 38/842
EXP: 1934420
Next: 50266

Since: 02-19-07
From: durff

Last post: 4481 days
Last view: 4004 days
Although I don't know that much about Zilog 80 Assembly.... it's usually the case that certain registers are designed for one thing more than the other. With just a casual glance at the Z80 instruction set, it looks like the E register was designed to help change the program counter, whereas the A register is more general purpose. Things like this can restrict how you code, but you have to deal with them.

____________________
Zelda Hacking Forum
hobbies: delectatio morosa

Drag
Posted on 03-11-07 07:27 PM Link | Quote | ID: 13908


Spike
Dragon
Level: 57

Posts: 148/705
EXP: 1482139
Next: 3789

Since: 02-19-07
From:

Last post: 3921 days
Last view: 3921 days
I'm assuming this is gameboy z80, since it's slightly different than plain z80.

Anyway, yeah, like MON said, certain registers are designed for certain functions. You'll notice that in 6502, you can't do every function with every register either. It's just something you need to work around. Foe example, HL is designed for indirect addressing, and can be used for indexed addressing, so you can do stuff like:

jp (hl)

but you can't do something like

jp (de)

You can also

ld a,(hl)
ld a,(de)
ld a,(bc)

but you can only do that with A. All of the other registers can only use (hl).

____________________

HyperHacker
Posted on 03-25-07 05:39 AM Link | Quote | ID: 18944

...
Level: 73

Posts: 14/1220
EXP: 3364881
Next: 120987

Since: 03-25-07
From: no

Last post: 6084 days
Last view: 6068 days
Yep, short answer, not all instructions can be used with all registers. Fortunately, GBZ80 has some very nice instructions like ldi a,(hl).

Main - ROM Hacking - Z80 Question New thread | New reply

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 0.028 seconds. (339KB of memory used)
MySQL - queries: 47, rows: 70/71, time: 0.016 seconds.