Fixed queue prediction bug for labels and procs

Fixed problem parsing "-" with single number expressions
Uploaded 1.02 win32 binary
This commit is contained in:
David Anderson 2004-08-21 06:20:27 +00:00
parent 49ee255fa4
commit 051657714c
4 changed files with 21 additions and 8 deletions

View File

@ -1241,8 +1241,7 @@ Start:
} }
case OP_SDIV_ALT: case OP_SDIV_ALT:
{ {
CHK_PARAMS(1); CHK_PARAMS(0);
PUSH_PARAM(1, Sym_Dat);
break; break;
} }
case OP_UMUL: case OP_UMUL:
@ -1257,8 +1256,7 @@ Start:
} }
case OP_UDIV_ALT: case OP_UDIV_ALT:
{ {
CHK_PARAMS(1); CHK_PARAMS(0);
PUSH_PARAM(1, Sym_Dat);
break; break;
} }
case OP_ADD: case OP_ADD:
@ -2310,7 +2308,7 @@ int Compiler::DerefSymbol(std::string &str, SymbolType sym)
{ {
ProcMngr::AsmProc *p = 0; ProcMngr::AsmProc *p = 0;
if ( ((p = PROC->FindProc(str)) == NULL) || p->ASM == NULL) if ( ((p = PROC->FindProc(str)) == NULL) )
{ {
/* Labels we handle differently. /* Labels we handle differently.
Add it to the label queue Add it to the label queue
@ -2318,6 +2316,9 @@ int Compiler::DerefSymbol(std::string &str, SymbolType sym)
p = PROC->AddProc(S, NULL); p = PROC->AddProc(S, NULL);
PROC->QueueProc(str, CurAsm()); PROC->QueueProc(str, CurAsm());
val = ProcMngr::ncip; val = ProcMngr::ncip;
} else if (p->ASM == NULL) {
PROC->QueueProc(str, CurAsm());
val = ProcMngr::ncip;
} else { } else {
val = p->ASM->cip; val = p->ASM->cip;
} }
@ -2355,6 +2356,9 @@ int Compiler::DerefSymbol(std::string &str, SymbolType sym)
L = CLabels->AddLabel(S, LabelMngr::ncip); L = CLabels->AddLabel(S, LabelMngr::ncip);
CLabels->QueueLabel(str, CurAsm()); CLabels->QueueLabel(str, CurAsm());
LabelStack.push(str); LabelStack.push(str);
} else if (L->cip == LabelMngr::ncip) {
//if we don't queue the label the jump won't be resolved!
CLabels->QueueLabel(str, CurAsm());
} }
val = L->cip; val = L->cip;

View File

@ -126,7 +126,7 @@ void get_options(int argc, char **argv, Compiler &Prog)
void print_version() void print_version()
{ {
printf("Small/AMX Assembler 1.01\n"); printf("Small/AMX Assembler 1.02\n");
printf("(C)2004 David 'BAILOPAN' Anderson\n"); printf("(C)2004 David 'BAILOPAN' Anderson\n");
} }

View File

@ -98,7 +98,7 @@ void CExpr::Set(std::string &text)
int CExpr::DeHex(std::string blk) int CExpr::DeHex(std::string blk)
{ {
size_t pos = 0, xc = 0, xpos = 0; size_t pos = 0, xc = 0, xpos = 0, ms = 0;
/* run through the characters */ /* run through the characters */
for (pos = 0; pos < blk.size(); pos++) for (pos = 0; pos < blk.size(); pos++)
{ {
@ -108,6 +108,9 @@ int CExpr::DeHex(std::string blk)
if (xc > 1) if (xc > 1)
break; break;
xpos = pos; xpos = pos;
} else if (blk[pos] == '-') {
if (pos != 0)
ms = 1;
} else if (blk[pos] != ' ' } else if (blk[pos] != ' '
&& (blk[pos] < '0' || blk[pos] > '9') && (blk[pos] < '0' || blk[pos] > '9')
&& (!xc || (xc && !IsHex(blk[pos])))) { && (!xc || (xc && !IsHex(blk[pos])))) {
@ -120,6 +123,11 @@ int CExpr::DeHex(std::string blk)
CError->ErrorMsg(Err_Unexpected_Char, 'x'); CError->ErrorMsg(Err_Unexpected_Char, 'x');
return 0; return 0;
} }
if (ms)
{
CError->ErrorMsg(Err_Unexpected_Char, '-');
return 0;
}
if (xc) if (xc)
{ {
if (xpos == 0 || blk[xpos-1] != '0') if (xpos == 0 || blk[xpos-1] != '0')
@ -139,9 +147,10 @@ int CExpr::DeHex(std::string blk)
blk[pos] -= 32; blk[pos] -= 32;
if (blk[pos] >= 16 || blk[pos] < 0) if (blk[pos] >= 16 || blk[pos] < 0)
{ {
assert(0);
if (CError) if (CError)
{
CError->ErrorMsg(Err_Unexpected_Char, blk[pos]); CError->ErrorMsg(Err_Unexpected_Char, blk[pos]);
}
return 0; return 0;
} }
j *= 16; j *= 16;

Binary file not shown.