Menu

MP 3.0 shift operations swapped?

akwky
2010-06-26
2013-04-25
  •  akwky

    akwky - 2010-06-26

    Hi, I have downloaded last MP 3.0 version and I am getting unexpected results using shr and shl operators. This sample program prints number 246, but I beleive that "123 shr 1" should be equivalent to "123 div 2".

    program NewProject;
    begin
      drawText('123 shr 1 = ' + IntegerToString(123 shr 1), 0, 0);
      repaint;
      delay(2000);
    end.
    
     
  • Javier Santo Domingo

    I was expecting some bug, almost 650 downloads and not a single report on this release, too good to be true :p, but here it is… and now guys, THAT is a bug!

    And yes, the operators are swapped when being written to the bytecode, in parser.c:4037 we can read:

                case OP_SHR:
                    bytecode_append(current_block->code, ishl$);
                    break;
                case OP_SHL:
                    bytecode_append(current_block->code, ishr$);
                    break;
    

    A typo, or a copy/paste mistake, dunno, but for everyone reading this (and since I know there are some out there using the Artem's 007/009 command-line versions) I checked the code and this bug is present from the 007, so watch out! I will be fixing this but in the official 3.0 version only (the 007/009/009.SIMPLE will remain like they are in the SVN, just like Artem released them). If you want to fix this manually in your 007/009 local version just swap the switch options or the bytecode opcode and recompile it; and just in case check also you have fixed the real numbers parsing and the other bugs I already fixed -just compare your local version files against the MPC.3.0.IDE files in the SVN repository-.

    Thanks for your report!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.