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
#2
The ZXBASM should support IXh, and IXl since the optimizer (-O3) uses them. If it does not, then it's a bug.
Let me check it...

Update:.- Only INC/DEC (IXh | IXl) where being used, and a few more.
Now most of them has been added:
Code:
OPCODE       INSTRUCTION        OPCODE        INSTRUCTION
  -----------  -----------------  ------------  ------------
  #DD #24      INC  IXH           #FD #24       INC  IYH
  #DD #25      DEC  IXH           #FD #25       DEC  IYH
  #DD #26 nn   LD   IXH,nn        #FD #26 nn    LD   IYH,nn
  #DD #2C      INC  IXL           #FD #2C       INC  IYL
  #DD #2D      DEC  IXL           #FD #2D       DEC  IYL
  #DD #2E nn   LD   IXL,nn        #FD #2E nn    LD   IYL,nn
  #DD #44      LD   B,IXH         #FD #44       LD   B,IYH
  #DD #45      LD   B,IXL         #FD #45       LD   B,IYL
  #DD #4C      LD   C,IXH         #FD #4C       LD   C,IYH
  #DD #4D      LD   C,IXL         #FD #4D       LD   C,IYL
  #DD #54      LD   D,IXH         #FD #54       LD   D,IYH
  #DD #55      LD   D,IXL         #FD #55       LD   D,IYL
  #DD #5C      LD   E,IXH         #FD #5C       LD   E,IYH
  #DD #5D      LD   E,IXL         #FD #5D       LD   E,IYL
  #DD #60      LD   IXH,B         #FD #60       LD   IYH,B
  #DD #61      LD   IXH,C         #FD #61       LD   IYH,C
  #DD #62      LD   IXH,D         #FD #62       LD   IYH,D
  #DD #63      LD   IXH,E         #FD #63       LD   IYH,E
  #DD #64      LD   IXH,IXH       #FD #64       LD   IYH,IYH
  #DD #65      LD   IXH,IXL       #FD #65       LD   IYH,IYL
  #DD #67      LD   IXH,A         #FD #67       LD   IYH,A
  #DD #68      LD   IXL,B         #FD #68       LD   IYL,B
  #DD #69      LD   IXL,C         #FD #69       LD   IYL,C
  #DD #6A      LD   IXL,D         #FD #6A       LD   IYL,D
  #DD #6B      LD   IXL,E         #FD #6B       LD   IYL,E
  #DD #6C      LD   IXL,IXH       #FD #6C       LD   IYL,IYH
  #DD #6D      LD   IXL,IXL       #FD #6D       LD   IYL,IYL
  #DD #6F      LD   IXL,A         #FD #6F       LD   IYL,A
  #DD #7C      LD   A,IXH         #FD #7C       LD   A,IYH
  #DD #7D      LD   A,IXL         #FD #7D       LD   A,IYL
  #DD #84      ADD  A,IXH         #FD #84       ADD  A,IYH
  #DD #85      ADD  A,IXL         #FD #85       ADD  A,IYL
  #DD #8C      ADC  A,IXH         #FD #8C       ADC  A,IYH
  #DD #8D      ADC  A,IXL         #FD #8D       ADC  A,IYL
  #DD #94      SUB  IXH           #FD #94       SUB  IYH
  #DD #95      SUB  IXL           #FD #95       SUB  IYL
  #DD #9C      SBC  A,IXH         #FD #9C       SBC  A,IYH
  #DD #9D      SBC  A,IXL         #FD #9D       SBC  A,IYL
  #DD #A4      AND  IXH           #FD #A4       AND  IYH
  #DD #A5      AND  IXL           #FD #A5       AND  IYL
  #DD #AC      XOR  IXH           #FD #AC       XOR  IYH
  #DD #AD      XOR  IXL           #FD #AD       XOR  IYL
  #DD #B4      OR   IXH           #FD #B4       OR   IYH
  #DD #B5      OR   IXL           #FD #B5       OR   IYL
  #DD #BC      CP   IXH           #FD #BC       CP   IYH
  #DD #BD      CP   IXL           #FD #BD       CP   IYL
Reply
#3
Forgot to mention this version is already uploaded. You can download it zxbasic-1.2.5r1513h.msi at <!-- m --><a class="postlink" href="http://www.boriel.com/files/zxb/">http://www.boriel.com/files/zxb/</a><!-- m -->
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)