Menu

if bug?

Marcoos
2014-02-04
2014-02-07
  • Marcoos

    Marcoos - 2014-02-04

    These are two versions of the same program, the first does not work,
    the second compiles correctly
    I something wrong or is this a bug?
    Tanks, Marco

    if (test1<> 0x55)|(test2<> 0xAA) THEN
        Goto SetMeasure
    END IF
    
    if (test1<> 0x55) THEN
        Goto SetMeasure
    END IF
    if (test2<> 0xAA) THEN
        Goto SetMeasure
    END IF
    
     
  • Anobium

    Anobium - 2014-02-04

    Try the following. Please post the results.

    if ((test1<> 0x55) = 1 )| ((test2<> 0xAA) = 1 )THEN
    Goto SetMeasure
    END IF

     
  • Anobium

    Anobium - 2014-02-04

    Or try.

    ((test1<> 0x55) ) | ((test2<> 0xAA) )

     
  • Chuck Hellebuyck

    I would have thought you would get an error but I believe there should be parenthesis around the whole IF operand.
    i.e.
    if ((test1<> 0x55)|(test2<> 0xAA))

     
  • Marcoos

    Marcoos - 2014-02-04

    I think it's just a bug, I tested all three variants without success, I'm testing it with Proteus and the generated code is obviously wrong.
    What I seem a strange and that gives me doubts about my work is that writing a program, it is trivial to have such a condition, and it seems strange that it has not happened before.
    For now I have taken the expression that I showed you working, but I think that must be corrected.
    For now, thanks, Marco

     
  • Anobium

    Anobium - 2014-02-04

    I have had the same experience last year.

    Please post your full code (the code that does not work), what is the date of your GCB compiler?

     
  • Anobium

    Anobium - 2014-02-04

    I an not sure that I understand your code. I have just run and get the results I expected, then, because I wanted to validate the results I ran the same tests in excel.

    Four tests using the values in the first two columns.
    With a calc of =IF(OR(A1<>85, B1<>170),"true","false"), where the data is in column A and B, the results are in column C
    A B C
    85 170 false
    85 171 true
    86 170 true
    86 171 true

    And, the results in GCB. The same.
    false
    true
    true
    true

    With code as shown below changing the values for each loop.

    test1 = 0x55
    test2 = 0xAa

    if ((test1<> 0x55) ) | ((test2<> 0xAA) ) THEN
    HSerPrint "true"
    else
    HSerPrint "false"

    END IF

    Please post your full code (the code that does not work), what is the date of your GCB compiler?

     

    Last edit: Anobium 2014-02-04
  • Marcoos

    Marcoos - 2014-02-05

    in attached the two different test, with the generated assembler. You can see then whe I use the faulty mode the assembler execute a compmplement instruction, that is the error.
    The compiler is the V9.30 22/09/2013
    Marco

     
  • Marcoos

    Marcoos - 2014-02-07

    Hi
    I have been worked to debug the problem, and the problem whith the pic compiler is not present, the assembler is quitly different, and work fine.
    Meanwhile I have found another bug, due to an alignment error of my istruction, which exits the program without performing The Else.

    ;This not work but no error in compiling
    if AppCountDown < MinCountDown Then
        Triac = 0 Else
        Triac = 1
    end if
    
    ;This work fine
    if AppCountDown < MinCountDown Then
        Triac = 0
    Else
        Triac = 1
    end if
    

    I think that even in the first bug is an error in the management of complexity or managing the complexity of the line
    Marco

     
    • Anobium

      Anobium - 2014-02-07

      Please use your method that works.

      To the best of my knowledge this is not supported. The latest help file has this information.

      ELSE must be on a separate line in the source code.

      Supported

      ....
      <instruction> ' is supported
      

      ELSE
      <instruction>
      .....

      Not Supported

      ......
      <instruction> ELSE ' is not supported but will compile 
      <instruction> 
      .....
      
       
  • Anobium

    Anobium - 2014-02-07

    Regarding the compiler output from the different chips. Already spotted the difference when my code work (PIC) and your did not. :-)

    Will respond when we have some news. I have added this the known issues list.

     
  • Marcoos

    Marcoos - 2014-02-07

    Anobium thanks,
    I pointed out that I was writing my mistake, the problem is the failure to report the compiler! ;-)
    I really like working with the GCB and I'm building a code generator for GCB state machine from one program to always open source
    I will alert you as soon as usable
    Marco

     

Log in to post a comment.