| |||
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 |
| ||
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 |
| ||
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 |
| ||
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 |
| ||
... 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 |
© 2005-2023 Acmlm, blackhole89, Xkeeper et al. |
MySQL - queries: 47, rows: 70/71, time: 0.016 seconds. |