Menu

Is it possible to use iyh, iyl registers in inline asm?

Help
sverx
2017-04-06
2017-04-06
  • sverx

    sverx - 2017-04-06

    As per the title, I've got an inline asm block in which I'm using iyh and iyl z80 registers such as for example the following fragment:

    __asm
      ld d,iyh
      ld iyl,#0x00
    __endasm;
    

    and my source won't compile. It's blaming me (twice - one for each line) for using an

    Error: (a) machine specific addressing or addressing mode error

    how can I fix this?

    I'm using

    SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.6.0 #9615 (MINGW32)
    published under GNU General Public License (GPL)

    Thanks!

     
  • alvin

    alvin - 2017-04-07

    asz80 does not support those undocumented instructions. There's some previous discussion here .

    You can probably get away with doing something like:

    __asm
      defb #0xfd
      ld d,h
      defb #0xfd
      ld l,#0x00
    __endasm;
    

    This may cause errors if you are allowing the peepholer to look into inlined asm; at the minimum the peepholer won't be able to look through the "defb".

    (I personally prefer to completely separate asm source from c source to keep the c portion portable and to have control over things like area assignment. It's fairly easy to do :- there's a brief example here for the z80 where a simple "cpm.s" assembly file provides a couple of bdos functions. Normally you'd have to add a function prototype in a header to make the compiler aware of an asm function but "putchar" is already prototyped by sdcc in stdio.h so that doesn't have to be done here)

     
  • sverx

    sverx - 2017-05-05

    I think it's funny that those instructions are still treated as 'undocumented'... it's completely useless nowadays IMHO.

    BTW, back in topic, it seems I can't use

    defb #0xfd
    

    when I do, all I get is

    Error: <q> missing or improper operators, terminators, or delimiters
    

    is that defb something I can't use in a inline asm block?

     
    • Philipp Klaus Krause

      That should be .db insteaf of defb.

      Philipp

       

Log in to post a comment.