Inline assembly push/pop?

Discussion about other targets
Post Reply
DJ Sures
Member
Posts: 67
Joined: Sun Dec 11, 2022 12:41 pm

Inline assembly push/pop?

Post by DJ Sures »

I do a ton of inline assembly in NABULIB and cloud cpm bios. Because the compiler doesn't know what registers are being used in the inline, should i be making the habit of pushing and popping the registers that i mangle?

i.e.

Code: Select all

  void vdp_refreshViewPort() {

    vdp_setWriteAddress(_vdpPatternNameTableAddr);

    __asm

      push hl; <------------------------------
      push de; <------------------------------

      ld hl, __vdp_textBuffer;
      ld de, (__vdpTextBufferSize); 

      vdp_refreshViewPortLoop3:

        ld a, (hl);
        out (0xa0), a;

        inc hl;
        dec de;

        ld A, D;                 
        or E;                   
        jp nz, vdp_refreshViewPortLoop3;

      pop de;  <------------------
      pop hl;   <------------------
    __endasm;
  }
PS, ha offtopic you may be wondering why i'm looping and not using OUTI... the VDP can't keep up and it looses bits near the end
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: Inline assembly push/pop?

Post by dom »

I'm not certain to be honest - I've got a memory of a comment somewhere indicating that when a __asm block is hit, the registers are reloaded afterwards if required.

But, in this case, what not use use vdp_vwrite() from <video/tms9918.h> ?
DJ Sures
Member
Posts: 67
Joined: Sun Dec 11, 2022 12:41 pm

Re: Inline assembly push/pop?

Post by DJ Sures »

ha - well there's so much in z88dk that i'm still learning to find stuff :D Will explore!
Post Reply