void asm_pre(void) { sprintf(obuf,"iasm_%d",cnum); // out("\r\nvoid "); // output PROTO // out(obuf); // out("(void);\r\n"); //not needed: and does not work anyways out("\r\n#pragma aux "); out(obuf); out("=\\\r\n"); first=1; } void asm_done(void) { out(";\r\n"); out(obuf); out("();\r\n"); cnum++; if (cnum==65535) errorf("To many ASM blocks!"); } void out_asm(byte *s) { //output buf! //first remove JUNK in s word p,st,l; p=0; while (*(s+p)==32) p++; st=p; //starting pos p=strlen(s); while (*(s+p)==32) p--; *(s+p+1)=0; p=strlen(s+st); if (!p) return; //nothing there! if (first) { first=0; } else out(",\\\r\n"); out("\""); out(s+st); out("\""); } //pre-process file void prefile(void) { word pb; // ptr in buf word pd,p1,p2,p3,ttt; byte a,b,c; byte f1; //misc flags byte f2; byte f3; byte f4; byte f5; while (!EOFF[ch]) { readln(); //get 1st word (looking for ASM {} blocks) pb=0; while (buf[pb]) { a=buf[pb]; if (a==' ') {pb++;continue;} if (a=='_') {pb++;continue;} //in case it's _asm,__asm,___asm,etc. break; } f5=0; if (!memcmp(buf+pb,"asm",3)) { f5=*(buf+pb+3); if ((f5==0) || (f5==32) || (f5=='{')) f5=1; else f5=0; } if (f5) { //make sure this is an ASM thingy //check if line is empty if so then read in next line until it's not empty f5=0; ttt=pb; pb+=3; while(buf[pb]) { if (buf[pb]==32) {pb++;continue;} f5=1;break; //there is stuff on this line } if (!f5) { //the rest of line is empty f3=1; //starting on another line do { readln(); if (EOFF[ch]) errorf("ASM line is empty"); pb=0; while(buf[pb]) { if (buf[pb]==32) {pb++;continue;} else {f3=0;break;} } }while (f3); } else { f3=0; pb=ttt; } // do ASM thingy //chek if next char is a {, if it's not then we have a 1 liner f1=0; //was thingy found? f2=pb; //save for l8r pb=0; while (buf[pb]) { if (buf[pb]=='{') {f1=1;break;} pb++; } if (f1) { //start outputing ASM until we hit } pb++; //skip over { asm_pre(); //setup next ASM thingy f1=1; while (f1) { b=strlen(buf+pb); for(a=pb;a') {buf[pb]=0;break;} } pb=ttt; file=buf+pb; dofile(); //recursive call continue; } strcat(buf,enter); out(buf); //output normal string (may be mod by string stuff!!) } } void out(byte *str) { word a; a=strlen(str); if (a+bufp1>bufsiz) { write(ho1,bufo1,bufp1); bufp1=0; } memcpy(bufo1+bufp1,str,a); bufp1+=a; } void setup(void) { //open files and setup out2nd ho1=open("c.tmp",O_BINARY|O_WRONLY|O_CREAT|O_TRUNC); if (ho1==-1) error("creating c.tmp"); ho1on=1; inc=(void*)getenv("INCLUDE"); if ((dword)inc==ERROR) { printf("Warning:INCLUDE not set in enviroment\n"); } else { incsiz=strlen(inc); } } void flush(void) { write(ho1,bufo1,bufp1); bufp1=0; close(ho1); ho1on=0; }