Merge pull request #114 from Ben10do/fix-asm-tests

Fix issues in rgbasm raised by the tests
This commit is contained in:
AntonioND
2017-02-27 21:09:04 +00:00
committed by GitHub
2 changed files with 10 additions and 2 deletions

View File

@@ -142,8 +142,9 @@ void copyrept( void )
{ {
SLONG level=1, len, instring=0; SLONG level=1, len, instring=0;
char *src=pCurrentBuffer->pBuffer; char *src=pCurrentBuffer->pBuffer;
char *bufferEnd = pCurrentBuffer->pBufferStart + pCurrentBuffer->nBufferSize;
while( *src && level ) while( src < bufferEnd && level )
{ {
if( instring==0 ) if( instring==0 )
{ {
@@ -221,8 +222,9 @@ void copymacro( void )
{ {
SLONG level=1, len, instring=0; SLONG level=1, len, instring=0;
char *src=pCurrentBuffer->pBuffer; char *src=pCurrentBuffer->pBuffer;
char *bufferEnd = pCurrentBuffer->pBufferStart + pCurrentBuffer->nBufferSize;
while( *src && level ) while( src < bufferEnd && level )
{ {
if( instring==0 ) if( instring==0 )
{ {

View File

@@ -316,6 +316,9 @@ rpn_DIV(struct Expression * expr, struct Expression * src1,
struct Expression * src2) struct Expression * src2)
{ {
joinexpr(); joinexpr();
if (src2->nVal == 0) {
fatalerror("division by zero");
}
expr->nVal = (expr->nVal / src2->nVal); expr->nVal = (expr->nVal / src2->nVal);
pushbyte(expr, RPN_DIV); pushbyte(expr, RPN_DIV);
} }
@@ -325,6 +328,9 @@ rpn_MOD(struct Expression * expr, struct Expression * src1,
struct Expression * src2) struct Expression * src2)
{ {
joinexpr(); joinexpr();
if (src2->nVal == 0) {
fatalerror("division by zero");
}
expr->nVal = (expr->nVal % src2->nVal); expr->nVal = (expr->nVal % src2->nVal);
pushbyte(expr, RPN_MOD); pushbyte(expr, RPN_MOD);
} }