Skip to content

Commit

Permalink
Fixed SIZE in EXOS modules, detect multiple sizes as error
Browse files Browse the repository at this point in the history
  • Loading branch information
istvan-v committed Apr 18, 2019
1 parent 7744327 commit c65a337
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
14 changes: 5 additions & 9 deletions direct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ void dirHEADER() {
if (val<5 || val>6) return;
adres = (val!=6 ? 0x00f0 : 0xbffa);
e[0] = int(val<<8);
if (!comma(lp)) val=endadres;
if (!comma(lp)) val=(size==-1 ? aint(endadres):(size+adres));
else ParseExpression(lp,val);
e[1] = int(val-(adres+16)); check16(e[1]);
if (e[1]>(adres<0x8000 ? 0xbf00 : 0x3ff6)) error("Bytes lost",0);
Expand Down Expand Up @@ -434,15 +434,10 @@ void dirENDMAP() {
void dirALIGN() {
aint val;
if (!ParseExpression(lp,val)) val=4;
switch (val) {
case 1: break;
case 2: case 4: case 8: case 16: case 32: case 64: case 128: case 256:
case 512: case 1024: case 2048: case 4096: case 8192: case 16384: case 32768:
if (val<1 || val>32768 || (val&(val-1))!=0) error("Illegal align",0);
else {
val=(~adres+1)&(val-1);
EmitBlock(0,val);
break;
default:
error("Illegal align",0); break;
}
}

Expand Down Expand Up @@ -514,7 +509,8 @@ void dirSIZE() {
#endif
if (!ParseExpression(lp,val)) { error("Syntax error",bp,CATCHALL); return; }
if (pass==2) return;
if (size!=(aint)-1) { error("Multiple sizes?",0); return; }
if (relocpass) val=val<<1;
else if (size!=(aint)-1) { error("Multiple sizes?",0,PASS1); return; }
size=val;
}

Expand Down
8 changes: 3 additions & 5 deletions sjasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,9 @@ void relocfile() {
Close(); relocpass=false;
if (!(output=freopen(destfilename,"rb",output)))
error("Error reopening output file",0,FATAL);
if (fseek(output,0,SEEK_END)<0 || long(fsize=size_t(ftell(output)))<0 ||
fseek(output,0,SEEK_SET)<0) {
error("Error seeking output file",0,FATAL); return;
}
if (fsize<2 || fsize>(0xe380<<1) || endadres<1 || endadres>0xe380)
if (size!=-1) endadres=int(size>>1);
fsize=size_t(destlen);
if (fsize<2 || fsize>(0xe380<<1) || fsize!=(size_t(endadres)<<1))
error("Invalid relocatable module size",0,FATAL);
if (!(buf = (unsigned char *) malloc((fsize*3+64)*sizeof(unsigned char))))
error("Error allocating memory",0,FATAL);
Expand Down

0 comments on commit c65a337

Please sign in to comment.