Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IXh and IXl (*solved*)
#1
I noticed that the assembler doesn't like using IX and IY as half registers. Is it unsupported, or using a different syntax than the one I expected - LD IXH,A ?

Technically, they aren't official Zilog instructions, but most assemblers go for them. It's sometimes really handy to load IX and IY in halves, or you desperately need that extra register :-)

From a manual on assembler:


More Control Over Index Registers
You know, you can access the high and low bytes of IX and IY. It's a little more complicated because the instructions aren't officially supported by ZiLog, and it is a little on the unelegant side. Nevertheless they can be useful in some circumstances, like when all your registers are locked up and you need an 8-bit counter bad.
The high byte of IX is called either IXH or HX (remember these are unofficial registers so there are no standard names). The low byte is called either IXL or LX. The high and low bytes of IY are named similarly.

To use a part of an index register in an instruction:

Pick an instruction that allows both H and L to be used as an operand, excepting shifts, rotates, BIT, SET, and RES.
Use H if you want the high byte, or L if you want the low byte.
Immediately precede this instruction with .DB $DD to use the IX half-registers, or .DB $FD to use the IY half-registers.
Example: LD E, IXH
.DB $DD
LD E, H

Example: SUB IYL
.DB $FD
SUB L

Be aware that once you specify a prefix, you are locked into using that index register's half-registers. It is impossible to combine the half-registers of HL, IX, or IY in one instruction:
.DB $DD ;LD IXH, IXL
LD H, L
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)