Loading ...
Sorry, an error occurred while loading the content.

Re: [jallist] for-loop parameters ? Bug report

Expand Messages
  • Stef Mientki
    ... Then it s a bug ! The compiler gives an error, so if Nmodule is a variable, I guess it s value is of no importance ? I also tried it on the latest version
    Message 1 of 18 , Oct 1, 2003
    View Source
    • 0 Attachment
      Wouter van Ooijen wrote:
      > > Is it correct, that the statement below only works when Nmodule is a
      > constant (JAL 4.56) ?
      >
      > <JAL>
      > for (4 * Nmodule) loop
      > </JAL>
      >
      > -------------------
      >
      > should work for a variable, but note that it's value should be less than
      > 255 / 4 or you will be surprised...

      Then it's a bug !

      The compiler gives an error,
      so if Nmodule is a variable,
      I guess it's value is of no importance ?

      I also tried it on the latest version 4.58, same error ;-(

      Stef
    • mark gross
      It sure looks like a bug. var byte i = 25 for i * 3 loop -- 4 bytes n = n + 1 end loop gives: mark@THE-NNK5N6TSKXA ~/dev/jal/jal/testsuite/src $
      Message 2 of 18 , Oct 1, 2003
      View Source
      • 0 Attachment
        It sure looks like a bug.
        <JAL>
        var byte i = 25

        for i * 3 loop -- 4 bytes
        n = n + 1
        end loop
        </JAL>

        gives:

        mark@THE-NNK5N6TSKXA ~/dev/jal/jal/testsuite/src
        $ jal f877_20 for.jal
        jal 0.4.58 (GCC 3.2)
        > error: NULL pointer in squasher.c line 342

        > file 'for.jal' line 10 char 1
        > : for i * 3 loop -- 4 bytes
        > : ^^^

        Is this the error your get?

        --mgross

        Stef Mientki wrote:

        >
        >
        > Wouter van Ooijen wrote:
        > > > Is it correct, that the statement below only works when Nmodule is a
        > > constant (JAL 4.56) ?
        > >
        > > <JAL>
        > > for (4 * Nmodule) loop
        > > </JAL>
        > >
        > > -------------------
        > >
        > > should work for a variable, but note that it's value should be less than
        > > 255 / 4 or you will be surprised...
        >
        > Then it's a bug !
        >
        > The compiler gives an error,
        > so if Nmodule is a variable,
        > I guess it's value is of no importance ?
        >
        > I also tried it on the latest version 4.58, same error ;-(
        >
        > Stef
      • japus10
        Hi Stef, Mark, Please, Can you post this bug in SourceForge bug track? If the error it s what Marks post (source file and line) I can post it. Javi. ...
        Message 3 of 18 , Oct 1, 2003
        View Source
        • 0 Attachment
          Hi Stef, Mark,


          Please, Can you post this bug in SourceForge bug track? If the
          error it's what Marks post (source file and line) I can post it.


          Javi.



          --- In Jal_developers@yahoogroups.com, mark gross <mark@t...> wrote:
          > It sure looks like a bug.
          > <JAL>
          > var byte i = 25
          >
          > for i * 3 loop -- 4 bytes
          > n = n + 1
          > end loop
          > </JAL>
          >
          > gives:
          >
          > mark@THE-NNK5N6TSKXA ~/dev/jal/jal/testsuite/src
          > $ jal f877_20 for.jal
          > jal 0.4.58 (GCC 3.2)
          > > error: NULL pointer in squasher.c line 342
          >
          > > file 'for.jal' line 10 char 1
          > > : for i * 3 loop -- 4 bytes
          > > : ^^^
          >
          > Is this the error your get?
          >
          > --mgross
          >
          > Stef Mientki wrote:
          >
          > >
          > >
          > > Wouter van Ooijen wrote:
          > > > > Is it correct, that the statement below only works when
          Nmodule is a
          > > > constant (JAL 4.56) ?
          > > >
          > > > <JAL>
          > > > for (4 * Nmodule) loop
          > > > </JAL>
          > > >
          > > > -------------------
          > > >
          > > > should work for a variable, but note that it's value should be
          less than
          > > > 255 / 4 or you will be surprised...
          > >
          > > Then it's a bug !
          > >
          > > The compiler gives an error,
          > > so if Nmodule is a variable,
          > > I guess it's value is of no importance ?
          > >
          > > I also tried it on the latest version 4.58, same error ;-(
          > >
          > > Stef
        • Wouter van Ooijen
          The bug is present in the jal I use, so it was most probably present in the code the GPL effort started with. Test code: include 16f628_20 var byte n = 4, k =
          Message 4 of 18 , Oct 2, 2003
          View Source
          • 0 Attachment
            The bug is present in the jal I use, so it was most probably present in
            the code the GPL effort started with. Test code:

            include 16f628_20

            var byte n = 4, k = 1

            for 4 * n loop
            k = k + 2
            end loop

            pragma test assert k == 33


            Wouter van Ooijen

            -- -------------------------------------------
            Van Ooijen Technische Informatica: www.voti.nl
            consultancy, development, PICmicro products
          • japus10
            Hi Wouter, Tested the code with same results: jal 0.4.58 (GCC 3.2) ... Just added the bug in SourceForge (Report ID: 816441). The bug, squasher.c line 342,
            Message 5 of 18 , Oct 2, 2003
            View Source
            • 0 Attachment
              Hi Wouter,

              Tested the code with same results:

              jal 0.4.58 (GCC 3.2)
              > error: NULL pointer in squasher.c line 342
              > file 'Untitled.jal' line 5 char 1
              > : for 4 * n loop
              > : ^^^


              Just added the bug in SourceForge (Report ID: 816441).


              The bug, squasher.c line 342, it's in the "squash_for" tree
              subroutine and raises the error when trying to create a temporary
              control variable "assert_kind(p->loc, p->end->type, node_type);".




              Javi.





              --- In Jal_developers@yahoogroups.com, "Wouter van Ooijen"
              <wouter@v...> wrote:
              > The bug is present in the jal I use, so it was most probably
              present in
              > the code the GPL effort started with. Test code:
              >
              > include 16f628_20
              >
              > var byte n = 4, k = 1
              >
              > for 4 * n loop
              > k = k + 2
              > end loop
              >
              > pragma test assert k == 33
              >
              >
              > Wouter van Ooijen
              >
              > -- -------------------------------------------
              > Van Ooijen Technische Informatica: www.voti.nl
              > consultancy, development, PICmicro products
            • Javier Martínez
              Hi all, More tests: for 2 * n loop -- OK! k = k + 2 end loop for 3 * n loop -- Bad! k = k + 2 end loop for 4 * n loop -- Bad! k = k + 2 end loop for 5 *
              Message 6 of 18 , Oct 3, 2003
              View Source
              • 0 Attachment
                Hi all,

                More tests:


                for 2 * n loop -- OK!
                k = k + 2
                end loop

                for 3 * n loop -- Bad!
                k = k + 2
                end loop

                for 4 * n loop -- Bad!
                k = k + 2
                end loop

                for 5 * n loop -- Bad!
                k = k + 2
                end loop


                for ( 2 * n + 1 ) loop -- OK!
                k = k + 2
                end loop

                for ( 3 * n + 1 ) loop -- OK!
                k = k + 2
                end loop

                for ( 4 * n + 1 ) loop -- Bad!
                k = k + 2
                end loop

                for ( 5 * n + 1 ) loop -- Ok!
                k = k + 2
                end loop



                And ... :

                include 16f628_20

                var byte k = 1
                var byte n = 4
                var byte d = 19

                for ( d * n + 1) loop -- OK!
                k = k + 2
                end loop



                Where's the bug? Perhaps the bug is not where it raised ...


                Javi.
              • Eur van Andel
                ... How bad is bad? How many times is the loop executed? Does for (5 * n) loop k = k + 2 end loop work? -- Ir. E.E. van Andel, Fine Wire Heat Exchangers,
                Message 7 of 18 , Oct 6, 2003
                View Source
                • 0 Attachment
                  On 03 Oct 2003 19:25:22 +0200, Javier Martínez <japus11@...> wrote:

                  >for 3 * n loop -- Bad!
                  > k = k + 2
                  >end loop
                  >
                  >for 4 * n loop -- Bad!
                  > k = k + 2
                  >end loop
                  >
                  >for 5 * n loop -- Bad!
                  > k = k + 2
                  >end loop
                  How bad is bad?

                  How many times is the loop executed?

                  Does

                  for (5 * n) loop
                  k = k + 2
                  end loop

                  work?

                  --
                  Ir. E.E. van Andel, Fine Wire Heat Exchangers, Fiwihex B.V. www.fiwihex.com
                  Wierdensestraat 74, NL-7604 BK Almelo, The Netherlands eur@...
                  phone +31-546-491106 fax +31-546-491107 mobile +31-653-286573
                • mark gross
                  ... Its kindof bad in that it fails to compile, but the work around is obvious. --mgross
                  Message 8 of 18 , Oct 6, 2003
                  View Source
                  • 0 Attachment
                    Eur van Andel wrote:

                    > On 03 Oct 2003 19:25:22 +0200, Javier Martínez <japus11@...> wrote:
                    >
                    > >for 3 * n loop -- Bad!
                    > > k = k + 2
                    > >end loop
                    > >
                    > >for 4 * n loop -- Bad!
                    > > k = k + 2
                    > >end loop
                    > >
                    > >for 5 * n loop -- Bad!
                    > > k = k + 2
                    > >end loop
                    > How bad is bad?
                    >
                    > How many times is the loop executed?
                    >
                    > Does
                    >
                    > for (5 * n) loop
                    > k = k + 2
                    > end loop
                    >
                    > work?

                    Its kindof bad in that it fails to compile, but the work around is obvious.

                    --mgross
                  • Javier Martínez
                    Hi Mark, ... Am I still at 50Km/h while you re at 120? What s the work arround? Javi.
                    Message 9 of 18 , Oct 11, 2003
                    View Source
                    • 0 Attachment
                      Hi Mark,



                      > Its kindof bad in that it fails to compile, but the work around is obvious.
                      >

                      Am I still at 50Km/h while you're at 120? What's the work arround?



                      Javi.
                    • mark gross
                      ... I think you just need some coffee. ;) The assert is hapening while computing a temp var for the loop counter value. for 3*n loop with something like
                      Message 10 of 18 , Oct 11, 2003
                      View Source
                      • 0 Attachment
                        Javier Martínez wrote:

                        > Hi Mark,
                        >
                        >
                        >
                        > > Its kindof bad in that it fails to compile, but the work around is
                        > obvious.
                        > >
                        >
                        > Am I still at 50Km/h while you're at 120? What's the work arround?
                        >
                        >
                        >
                        > Javi.
                        >
                        I think you just need some coffee. ;)

                        The assert is hapening while computing a temp var for the loop counter
                        value.

                        for 3*n loop

                        with something like

                        temp_loop = 3 * n
                        for tepm_loop loop

                        --mgross
                      • Wouter van Ooijen
                        ... tip for the developers: when deriving the type of the loop variable there must probably be a follow() call. Wouter van Ooijen --
                        Message 11 of 18 , Oct 12, 2003
                        View Source
                        • 0 Attachment
                          > The assert is hapening while computing a temp var for the
                          > loop counter value.

                          tip for the developers: when deriving the type of the loop variable
                          there must probably be a follow() call.

                          Wouter van Ooijen

                          -- -------------------------------------------
                          Van Ooijen Technische Informatica: www.voti.nl
                          consultancy, development, PICmicro products
                        • japus10
                          ... ... better a hole coffe-shop! Javi.
                          Message 12 of 18 , Oct 12, 2003
                          View Source
                          • 0 Attachment
                            > I think you just need some coffee. ;)
                            >

                            ... better a hole coffe-shop!


                            Javi.
                          • japus10
                            ... Thanks Wouter, I ll see it this afternoon. Javi.
                            Message 13 of 18 , Oct 12, 2003
                            View Source
                            • 0 Attachment
                              --- In Jal_developers@yahoogroups.com, "Wouter van Ooijen"
                              <wouter@v...> wrote:
                              > > The assert is hapening while computing a temp var for the
                              > > loop counter value.
                              >
                              > tip for the developers: when deriving the type of the loop variable
                              > there must probably be a follow() call.
                              >


                              Thanks Wouter, I'll see it this afternoon.


                              Javi.
                            • japus10
                              Hi all, With this patch compile OK, but the output it s not good. I ll test it again at home. Javi. diff -u jal-0.4.58/jal/./squasher.c
                              Message 14 of 18 , Oct 20, 2003
                              View Source
                              • 0 Attachment
                                Hi all,

                                With this patch compile OK, but the output it's not good. I'll
                                test it again at home.


                                Javi.


                                <PATCH>
                                diff -u jal-0.4.58/jal/./squasher.c jal-0.4.58r2/jal/./squasher.c
                                --- jal-0.4.58/jal/./squasher.c Fri Jun 6 08:49:56 2003
                                +++ jal-0.4.58r2/jal/./squasher.c Mon Oct 20 10:08:58 2003
                                @@ -323,6 +323,8 @@
                                p->start = squash_node(p->start, scope);
                                p->step = squash_node(p->step, scope);
                                p->end = squash_node(p->end, scope);
                                +
                                + p->end = follow(p->end);

                                /* create start one ? */
                                if (p->start == NULL) {
                                </PATCH>


                                <JAL>
                                include 16f628_20

                                var byte n = 4, k = 1

                                for 4 * n loop
                                k = k + 2
                                end loop

                                </JAL>


                                <ASM>
                                ;; 003 : var byte n = 4, k = 1
                                ; var H'023:000' n
                                movlw H'04'
                                movwf H'023'
                                ; var H'024:000' k
                                movlw H'01'
                                movwf H'024'
                                ; var H'025:000' sq_temp_8016

                                ;; 005 : for 4 * n loop
                                ; var H'026:000' _loop_temp_8011
                                movf H'025',w
                                movwf H'026'
                                w_8099_ag: ; 000E
                                movf H'026',f
                                btfss H'003',2
                                goto w_8099_bo
                                w_8099_jb: ; 0011
                                goto w_8099_be
                                w_8099_bo: ; 0012

                                ;; 006 : k = k + 2
                                movlw H'02'
                                addwf H'024',f

                                decf H'026',f
                                goto w_8099_ag
                                w_8099_be: ; 0016

                                ;; 003 : idle_loop: page goto idle_loop
                                as_8028_idle_loop: ; 0016
                                goto as_8028_idle_loop
                                </ASM>
                              • japus10
                                Hi all, Yesterday I was playing with the patch suggested by Wouter (with the same success). There s no more NULL pointer error, but the operation it s not
                                Message 15 of 18 , Oct 20, 2003
                                View Source
                                • 0 Attachment
                                  Hi all,

                                  Yesterday I was playing with the patch suggested by Wouter (with
                                  the same success). There's no more NULL pointer error, but the
                                  operation it's not computed. If anyone (Wouter?) gives me another
                                  hand ... will be apreciated.


                                  Javi.



                                  --- In Jal_developers@yahoogroups.com, "japus10" <japus11@t...> wrote:
                                  > Hi all,
                                  >
                                  > With this patch compile OK, but the output it's not good. I'll
                                  > test it again at home.
                                  >
                                  >
                                  > Javi.
                                  >
                                  >
                                  > <PATCH>
                                  > diff -u jal-0.4.58/jal/./squasher.c jal-0.4.58r2/jal/./squasher.c
                                  > --- jal-0.4.58/jal/./squasher.c Fri Jun 6 08:49:56 2003
                                  > +++ jal-0.4.58r2/jal/./squasher.c Mon Oct 20 10:08:58 2003
                                  > @@ -323,6 +323,8 @@
                                  > p->start = squash_node(p->start, scope);
                                  > p->step = squash_node(p->step, scope);
                                  > p->end = squash_node(p->end, scope);
                                  > +
                                  > + p->end = follow(p->end);
                                  >
                                  > /* create start one ? */
                                  > if (p->start == NULL) {
                                  > </PATCH>
                                  >
                                  >
                                  > <JAL>
                                  > include 16f628_20
                                  >
                                  > var byte n = 4, k = 1
                                  >
                                  > for 4 * n loop
                                  > k = k + 2
                                  > end loop
                                  >
                                  > </JAL>
                                  >
                                  >
                                  > <ASM>
                                  > ;; 003 : var byte n = 4, k = 1
                                  > ; var H'023:000' n
                                  > movlw H'04'
                                  > movwf H'023'
                                  > ; var H'024:000' k
                                  > movlw H'01'
                                  > movwf H'024'
                                  > ; var H'025:000' sq_temp_8016
                                  >
                                  > ;; 005 : for 4 * n loop
                                  > ; var H'026:000' _loop_temp_8011
                                  > movf H'025',w
                                  > movwf H'026'
                                  > w_8099_ag: ; 000E
                                  > movf H'026',f
                                  > btfss H'003',2
                                  > goto w_8099_bo
                                  > w_8099_jb: ; 0011
                                  > goto w_8099_be
                                  > w_8099_bo: ; 0012
                                  >
                                  > ;; 006 : k = k + 2
                                  > movlw H'02'
                                  > addwf H'024',f
                                  >
                                  > decf H'026',f
                                  > goto w_8099_ag
                                  > w_8099_be: ; 0016
                                  >
                                  > ;; 003 : idle_loop: page goto idle_loop
                                  > as_8028_idle_loop: ; 0016
                                  > goto as_8028_idle_loop
                                  > </ASM>
                                • Wouter van Ooijen
                                  Hi everyone, I am still alive... I needed some new Jal functionality, so I took the big step and downloaded the GPL source. Juk, I don t like this split in
                                  Message 16 of 18 , Oct 22, 2003
                                  View Source
                                  • 0 Attachment
                                    Hi everyone, I am still alive...

                                    I needed some new Jal functionality, so I took the big step and
                                    downloaded the GPL source. Juk, I don't like this split in multiple
                                    files, nor the code formatting, but I guess I have to live with both :(

                                    But for the new functionality: I added support for multi-byte fuses (18F
                                    family). Can I send the modified code somewhere? I'd rather not do the
                                    checking-in myself, and someone might want to check my C syntax before
                                    checking in :)

                                    Wouter van Ooijen

                                    -- -------------------------------------------
                                    Van Ooijen Technische Informatica: www.voti.nl
                                    consultancy, development, PICmicro products
                                  • mark gross
                                    ... If you are using CVS to access the SF source code then if you can send the output from the following command to the list, or me directly, then I can merge
                                    Message 17 of 18 , Oct 22, 2003
                                    View Source
                                    • 0 Attachment
                                      Wouter van Ooijen wrote:

                                      > Hi everyone, I am still alive...
                                      >
                                      > I needed some new Jal functionality, so I took the big step and
                                      > downloaded the GPL source. Juk, I don't like this split in multiple
                                      > files, nor the code formatting, but I guess I have to live with both :(
                                      >
                                      > But for the new functionality: I added support for multi-byte fuses (18F
                                      > family). Can I send the modified code somewhere? I'd rather not do the
                                      > checking-in myself, and someone might want to check my C syntax before
                                      > checking in :)

                                      If you are using CVS to access the SF source code then if you can send
                                      the output from the following command to the list, or me directly, then
                                      I can merge it and get it into the version control system on source forge.
                                      "cvs diff -u "

                                      If you don't have CVS access to the code, then you can send the changed
                                      files or just the changes to me directly or to the list I'll do the
                                      merge and check in.

                                      BTW thanks for giving the GPL version we've been working on a try.

                                      --mgross

                                      >
                                    • Javier Martínez
                                      Hi Wouter, ... Thanks for this step. Perhaps it s nor so good as each one hope, but seems to be acceptable for all. ... What I m doing now is to send the patch
                                      Message 18 of 18 , Oct 22, 2003
                                      View Source
                                      • 0 Attachment
                                        Hi Wouter,

                                        > I needed some new Jal functionality, so I took the big step and
                                        > downloaded the GPL source. Juk, I don't like this split in multiple
                                        > files, nor the code formatting, but I guess I have to live with both :(
                                        >

                                        Thanks for this step. Perhaps it's nor so good as each one hope, but
                                        seems to be acceptable for all.

                                        > But for the new functionality: I added support for multi-byte fuses (18F
                                        > family). Can I send the modified code somewhere? I'd rather not do the
                                        > checking-in myself, and someone might want to check my C syntax before
                                        > checking in :)

                                        What I'm doing now is to send the patch file (cvs diff -u) attached
                                        with the email, and let Mark to do the commit. But if you want to do it
                                        by yourself, make the changes in cvs directly.


                                        Regards, Javi.
                                      Your message has been successfully submitted and would be delivered to recipients shortly.