/************************************************
 * TESTSD - Test Library stddef.h02 for py65mon *
 ************************************************/
 

//use -h option on command line
#include <stddef.h02>

const char txtstr = {
        "#TRUE=",", #FALSE=",
        "SAVREG($A,$B,$C)", " TEMP0,1,2=", 
        "RESREG()", " A,X,Y=", 
        "SETSRC(&$1234)"," SRCLO,HI=", " GETSRC()=",
        "SETDST(&$5678)"," DSTLO,HI=", " GETDST()="
      };
char txtidx;

char aa,xx,yy;

main:
  txtidx = 0;
  newlin();

  prttxt(); prbyte(#TRUE);
  prttxt(); prbyte(#FALSE);
  newlin(); newlin();

  temp0=0; temp1=0; temp3 = 0;
  prtlin(); savreg($A,$B,$C);
  prttxt(); prbyte(temp0);
  prtcma(); prbyte(temp1);
  prtcma(); prbyte(temp2);
  newlin(); 
 
  setreg(0,0,0);
  prtlin(); aa,yy,xx = resreg();
  prttxt(); prbyte(aa);
  prtcma(); prbyte(yy);
  prtcma(); prbyte(xx);
  newlin(); newlin();
  

  srclo = 0; srchi = 0;
  prtlin(); setsrc(&$1234);
  prttxt(); prbyte(srclo);
  prtcma(); prbyte(srchi);
  newlin();
  prttxt(); setreg(0,0,0);
  getsrc(); prtwrd();
  newlin();  newlin();

  dstlo = 0; dsthi = 0;
  prtlin(); setdst(&$5678);
  prttxt(); prbyte(dstlo);
  prtcma(); prbyte(dsthi);
  newlin();
  prttxt(); setreg(0,0,0);
  getdst(); prtwrd();
  newlin(); newlin();


goto exit;

void setreg(aa,yy,xx) {}

void prtwrd(aa,yy,xx) {
  prbyte(yy);
  prbyte(xx);
}

void prtcma() {prchr(',');}

void prtlin() {prttxt(); newlin();}

void prttxt() {
  while (txtstr[txtidx]) {
    //prbyte(txtidx);prchr(' ');
    prchr(txtstr[txtidx]);
    txtidx++;
  }
  txtidx++;
}
