#13 two bugs in %ROTATE

closed-fixed
None
5
2002-06-11
2002-05-25
Anonymous
No

Currently the bottom of the PP_ROTATE code in
preproc.c looks like this:

if (!mmac)
error(ERR_NONFATAL,
"`%%rotate' invoked outside a macro call");
mmac->rotate = mmac->rotate + reloc_value(evalresult);
if (mmac->rotate < 0)
mmac->rotate = mmac->nparam - (-mmac->rotate) %
mmac->nparam;
mmac->rotate %= mmac->nparam;

This is wrong. Not only must the code after the
error message reside in an else clause, but that
code must also check whether mmac->nparam is
equal to zero or not.

The following should do the trick:

if (!mmac) {
error(ERR_NONFATAL, "`%%rotate' invoked outside a
macro call");
} else {
mmac->rotate = mmac->rotate +
reloc_value(evalresult);
if (mmac->nparam == 0) {
error (ERR_NONFATAL, "`%%rotate' invoked in
macro with no parameters");
} else {
if (mmac->rotate < 0) {
mmac->rotate = mmac->nparam -
(-mmac->rotate) % mmac->nparam;
}
mmac->rotate %= mmac->nparam;
nasm_listEquate(list, reloc_value(evalresult));
}
}

And here is some code which exercises this:

%rotate 0

%rep 1
%rotate 0
%endrep

%macro crap 0
%rotate 0
%endmacro

crap

; eof

Discussion

  • Ed Beroset

    Ed Beroset - 2002-06-11
    • assigned_to: nobody --> beroset
     
  • Ed Beroset

    Ed Beroset - 2002-06-11
    • status: open --> open-fixed
     
  • Ed Beroset

    Ed Beroset - 2002-06-11
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks