// PreASMmbler V 1.04 32bit // By:Peter Quiring /*---------------------------------------------------------------------------- Version 1.04 NEW : Now the INCLUDE enviro str can have multiple paths : seperated by ; Version 1.03 NEW : 32bit using DOS32 : Buffered input/output (greatly increases speed!) : \r=13, \n=10, \0=0 (\n use to =13,10) Version 1.02 NEW : \0 will insert a ,0, into the string Version 1.01 NEW : Now handles comment blocks!!! known bugs: v1.0 -none known bugs: v0.1 áeta -can't not have ; or ' or " within quotes Current version limitations: - Keeps all files open (until they are done), so you need a handle for each file when there are includes... future improvments: -merge duplicate strings (now I could with 32bit app) ----------------------------------------------------------------------------*/ #include #include #include #define mh 64 //max handles (the incs) #define bufsiz 16*1024 //buffer size byte buf[256]; //current line byte *bufo1; byte *bufo2; word bufp1,bufp2; byte * bufin[mh]; word bufip[mh]; word bufis[mh]; word cnum; //current string number int ho1; // handle out for large ASM file (asm.tmp) byte ho1on; //handle above has been created int ho2; // handle out for special data segment! (_str_.tmp) int h; // current file handle int hs[mh]; // handles (all kept in place) (requires a lot of handles in config.sys) byte ch; // current handle # byte foundit; // flag to indicate we found #include! byte EOFF[mh]; // flag (indicates that we have hit EOF) byte EOFF2[mh]; // flag (indicates that the current buffer is last one) void flush(void); void error(byte *s) { printf("Error:%s\n",s); flush(); if (ho1on) close(ho1); unlink("asm.tmp"); exit(2); } void readln(void) { byte a=0; word p=0; word t; while (a!=10) { if (!bufis[ch]) { if (EOFF2[ch]) {EOFF[ch]=1;break;} t=read(h,bufin[ch],bufsiz); bufis[ch]=t; if (!t) { EOFF2[ch]=1; buf[p]=0; return; } bufip[ch]=0; } a=*(bufin[ch]+(bufip[ch]++)); bufis[ch]--; buf[p++]=a; if (p>200) error("Line too long"); if (a==13) buf[p-1]=0; } buf[p]=0; } byte *file; //pts to filename to open #include "pasm.inc" void main(void) { byte a; printf("Nexus Pre Assembler Ver 1.04 32bit (by : Peter Quiring)\n"); printf("Copyright (C) Nexus Systems 1995-1996. All rights reserved.\n"); ho1on=0; bufp1=0; bufp2=0; bufo1=malloc(bufsiz); bufo2=malloc(bufsiz); if ( ((dword)bufo1==ERROR) || ((dword)bufo2==ERROR) ) error("Out of RAM\n"); for(a=0;a