diff --git a/sjasm/directives.cpp b/sjasm/directives.cpp index 14daebe0..63caa4de 100644 --- a/sjasm/directives.cpp +++ b/sjasm/directives.cpp @@ -773,6 +773,12 @@ void dirINCTRD() { } void dirSAVESNA() { + + if (pass != LASTPASS) { + SkipParam(lp); + return; + } + bool exec = true; if (!DeviceID) { @@ -835,6 +841,12 @@ void dirEMPTYTAP() { } void dirSAVETAP() { + + if (pass != LASTPASS) { + SkipParam(lp); + return; + } + bool exec = true, realtapeMode = false; int headerType = -1; aint val; @@ -1059,6 +1071,11 @@ void dirSAVEBIN() { } void dirSAVEHOB() { + + if (pass != LASTPASS) { + SkipParam(lp); + return; + } aint val; char* fnaam, * fnaamh; int start = -1,length = -1; @@ -1136,6 +1153,12 @@ void dirEMPTYTRD() { } void dirSAVETRD() { + + if (pass != LASTPASS) { + SkipParam(lp); + return; + } + bool exec = true; if (!DeviceID) { @@ -1543,7 +1566,7 @@ void dirIFDEF() { */ EReturn res; if (!(id = GetID(lp))) { - Error("[IFDEF] Illegal identifier", 0, PASS1); return; + Error("[IFDEF] Illegal identifier", 0); return; } if (DefineTable.FindDuplicate(id)) { @@ -1594,7 +1617,7 @@ void dirIFNDEF() { */ EReturn res; if (!(id = GetID(lp))) { - Error("[IFNDEF] Illegal identifier", 0, PASS1); return; + Error("[IFNDEF] Illegal identifier", 0); return; } if (!DefineTable.FindDuplicate(id)) { @@ -1796,7 +1819,7 @@ void dirMACRO() { char* n; //if (!(n=GetID(lp))) { Error("Illegal macroname",0,PASS1); return; } if (!(n = GetID(lp))) { - Error("[MACRO] Illegal macroname", 0, PASS1); return; + Error("[MACRO] Illegal macroname", 0); return; } MacroTable.Add(n, lp); } @@ -1933,7 +1956,7 @@ void dirSTRUCT() { } if (!(naam = GetID(lp)) || !strlen(naam)) { - Error("[STRUCT] Illegal structure name", 0, PASS1); return; + Error("[STRUCT] Illegal structure name", 0); return; } if (comma(lp)) { IsLabelNotFound = 0; @@ -1948,7 +1971,7 @@ void dirSTRUCT() { ListFile(); while ('o') { if (!ReadLine()) { - Error("[STRUCT] Unexpected end of structure", 0, PASS1); break; + Error("[STRUCT] Unexpected end of structure", 0); break; } lp = line; /*if (White()) { SkipBlanks(lp); if (*lp=='.') ++lp; if (cmphstr(lp,"ends")) break; }*/ SkipBlanks(lp); @@ -2311,17 +2334,17 @@ void dirINCLUDELUA() { fnaam = GetFileName(lp); int error; - if (pass != 1) { + if (pass == LASTPASS && !FileExists(fnaam)) { + Error("[INCLUDELUA] File doesn't exist", fnaam); return; } - //WinExec ( "C:\\path\\to\\program.exe", SW_SHOWNORMAL ); - - if (!FileExists(fnaam)) { - Error("[INCLUDELUA] File doesn't exist", fnaam, PASS1); + if (pass != 1) { return; } + //WinExec ( "C:\\path\\to\\program.exe", SW_SHOWNORMAL ); + LuaLine = CurrentLocalLine; error = luaL_loadfile(LUA, fnaam) || lua_pcall(LUA, 0, 0, 0); if (error) { diff --git a/sjasm/parser.cpp b/sjasm/parser.cpp index 3b6bd7e1..b3991364 100644 --- a/sjasm/parser.cpp +++ b/sjasm/parser.cpp @@ -932,11 +932,11 @@ void ParseStructMember(CStructure* st) { switch (GetStructMemberId(lp)) { case SMEMBBLOCK: if (!ParseExpression(lp, len)) { - len = 1; Error("[STRUCT] Expression expected", 0, PASS1); + len = 1; Error("[STRUCT] Expression expected", 0); } if (comma(lp)) { if (!ParseExpression(lp, val)) { - val = 0; Error("[STRUCT] Expression expected", 0, PASS1); + val = 0; Error("[STRUCT] Expression expected", 0); } } else { val = 0; diff --git a/sjasm/reader.cpp b/sjasm/reader.cpp index dc2e0c72..1d032b64 100644 --- a/sjasm/reader.cpp +++ b/sjasm/reader.cpp @@ -257,8 +257,11 @@ char* getinstr(char*& p) { /* changes applied from SjASM 0.39g */ int check8(aint val, bool error) { - if (val != (val & 255) && ~val > 127 && error) { - Error("Bytes lost", 0); return 0; + if ((val < -256 || val > 255) && error) { + char buffer[32]; + sprintf(buffer, "Bytes lost (0x%X)", val); + Warning(buffer, 0, LASTPASS); + return 0; } return 1; } @@ -266,23 +269,32 @@ int check8(aint val, bool error) { /* changes applied from SjASM 0.39g */ int check8o(long val) { if (val < -128 || val > 127) { - Error("Offset out of range", 0); return 0; + char buffer[32]; + sprintf(buffer,"Offset out of range (%+i)", val); + Error(buffer, 0, LASTPASS); + return 0; } return 1; } /* changes applied from SjASM 0.39g */ int check16(aint val, bool error) { - if (val != (val & 65535) && ~val > 32767 && error) { - Error("Bytes lost", 0); return 0; + if ((val < -65536 || val > 65535) && error) { + char buffer[32]; + sprintf(buffer, "Bytes lost (0x%X)", val); + Warning(buffer, 0, LASTPASS); + return 0; } return 1; } /* changes applied from SjASM 0.39g */ int check24(aint val, bool error) { - if (val != (val & 16777215) && ~val > 8388607 && error) { - Error("Bytes lost", 0); return 0; + if ((val < -16777216 || val > 16777215) && error) { + char buffer[32]; + sprintf(buffer, "Bytes lost (0x%X)", val); + Warning(buffer, 0, LASTPASS); + return 0; } return 1; } @@ -668,10 +680,10 @@ char* GetFileName(char*& p, bool convertslashes) { if (*p == '"') { ++p; } else { - Error("No closing '\"'", 0); + Error("No closing '\"'", 0, LASTPASS); } } else if (*p && o == 2 && *p != '>') { - Error("No closing '>'", 0); + Error("No closing '>'", 0, LASTPASS); } else if (*p) { ++p; } @@ -718,10 +730,10 @@ char* GetHobetaFileName(char*& p) { if (*p == '"') { ++p; } else { - Error("No closing '\"'", 0); + Error("No closing '\"'", 0, LASTPASS); } } else if (*p && o == 2 && *p != '>') { - Error("No closing '>'", 0); + Error("No closing '>'", 0, LASTPASS); } else if (*p) { ++p; } diff --git a/sjasm/sjio.cpp b/sjasm/sjio.cpp index ef578a08..fcdf6d45 100644 --- a/sjasm/sjio.cpp +++ b/sjasm/sjio.cpp @@ -191,17 +191,17 @@ void Warning(const char* fout, const char* bd, int type) { return; } - ++WarningCount; count = new char[25]; SPRINTF1(count, 25, "%d", WarningCount); DefineTable.Replace("_WARNINGS", count); - delete[] count; if (type == LASTPASS && pass != 3) { return; } + ++WarningCount; + if (pass > LASTPASS) { SPRINTF1(ep, LINEMAX2, "warning: %s", fout); } else { @@ -238,7 +238,7 @@ void CheckRamLimitExceeded() if (CurAddress >= 0x10000) { char buf[64]; - SPRINTF2(buf, 1024, "RAM limit exceeded 0x%X by %s", CurAddress, PseudoORG ? "DISP":"ORG"); + SPRINTF2(buf, 1024, "RAM limit exceeded 0x%X by %s", (unsigned int)CurAddress, PseudoORG ? "DISP":"ORG"); Warning(buf, 0, LASTPASS); CurAddress &= 0xFFFF; } @@ -246,7 +246,7 @@ void CheckRamLimitExceeded() if (PseudoORG) if (adrdisp >= 0x10000) { char buf[64]; - SPRINTF1(buf, 1024, "RAM limit exceeded 0x%X by ORG", adrdisp); + SPRINTF1(buf, 1024, "RAM limit exceeded 0x%X by ORG", (unsigned int)adrdisp); Warning(buf, 0, LASTPASS); adrdisp &= 0xFFFF; } diff --git a/sjasm/sjio.h b/sjasm/sjio.h index 06c77c83..155767e1 100644 --- a/sjasm/sjio.h +++ b/sjasm/sjio.h @@ -48,8 +48,8 @@ extern FILE* FP_UnrealList, * FP_Input; void OpenDest(int); void NewDest(char* newfilename, int mode); int FileExists(char* filename); -void Error(const char*, const char*, int = PASS2); -void Warning(const char*, const char*, int = PASS2); +void Error(const char*, const char*, int = LASTPASS); +void Warning(const char*, const char*, int = LASTPASS); void ListFile(); void ListFileSkip(char*); void CheckPage(); diff --git a/sjasm/z80.cpp b/sjasm/z80.cpp index 6bc8f676..d53a5258 100644 --- a/sjasm/z80.cpp +++ b/sjasm/z80.cpp @@ -950,7 +950,7 @@ namespace Z80 { b = (signed) callad; e[1] = callad & 255; e[2] = (callad >> 8) & 255; if (b > 65535) { - Error("[CALL] Bytes lost", 0); + Warning("[CALL] Bytes lost", 0, LASTPASS); } EmitBytes(e); /* (begin add) */ @@ -1173,8 +1173,8 @@ namespace Z80 { jmp = nad - CurAddress - 2; if (jmp < -128 || jmp > 127) { char el[LINEMAX]; - SPRINTF1(el, LINEMAX, "[DJNZ] Target out of range (%i)", jmp); - Error(el, 0); jmp = 0; + SPRINTF1(el, LINEMAX, "[DJNZ] Target out of range (%+i)", jmp); + Error(el, 0, LASTPASS); jmp = 0; } e[0] = 0x10; e[1] = jmp < 0 ? 256 + jmp : jmp; EmitBytes(e); @@ -1557,7 +1557,7 @@ namespace Z80 { b = (signed) jpad; e[1] = jpad & 255; e[2] = (jpad >> 8) & 255; if (b > 65535) { - Error("[JP] Bytes lost", 0); + Warning("[JP] Bytes lost", 0, LASTPASS); } } EmitBytes(e); @@ -1613,7 +1613,7 @@ namespace Z80 { /*if (pass == LASTPASS) { _COUT "AAAAAAA:" _CMDL jmp _CMDL " " _CMDL jrad _CMDL " " _CMDL CurAddress _ENDL; }*/ - SPRINTF1(el, LINEMAX, "[JR] Target out of range (%i)", jmp); + SPRINTF1(el, LINEMAX, "[JR] Target out of range (%+i)", jmp); Error(el, 0, LASTPASS); jmp = 0; }