
void OSNEWL()="\tjsr\t0xffe7";
void OSWRCHR(__reg("a") char)="\tjsr\t0xffee";
void OSBPUT(__reg("a") char,__reg("r0") char)="\tldy\tr0\n\tjsr\t$ffd4";

char __vdustate;

unsigned int __write(__reg("r0") char f,__reg("r2/r3") const char *p,__reg("r4/r5") unsigned int len)
{
  unsigned int n=len;
  while(n){
   char c=*p++;
   if(f<=3){
     if(c=='\n'&&!__vdustate)
       OSNEWL();
     else
       OSWRCHR(c);
   }else
     OSBPUT(c,f);
   n--;
  }
  return len;
}
