On Wed, Oct 15, 2003 at 09:49:18AM -0400, Jacob Welch wrote:
> Pedro Zorzenon Neto wrote:
> 
> > Code generated by mspgcc:
> >
> >.L3:
> >       mov     &menu_i, r15              ; Load 'menu_i' into r15
> >       rla     r15                       ; Rotate Left twice to adjust 
> >       index
> >       rla     r15                       ;   into a memory offset (element 
> >       size is 4)
> >       add     #menu_stack+2, r15        ; Add start of the array to the 
> >       offset
> >       add     #llo(12), @r15
> >       mov     @r15, r15
> >       jne     .L3
> >
> > Code that I think is correct:
> >
> >.L3:
> >       mov     &menu_i, r15 
> >       rla     r15
> >       rla     r15
> >       add     #menu_stack+2, r15
> >       add     #llo(12), @r15
> >       mov     @r15, r15 
> >       cmp     #0, r15                     ; <- this is missing
> >       jne     .L3
> >
> As I see it --
> 
> The add and move of @r15 to r15 followed by compare if zero to r15 is 
> not functionally different from just the add and move, since the add is 
> with @r15 and not r15.

Yes, you are right, BUT comparing above code to C instructions, as in
pzn mail, the correct cmp opcode is:

cmp #0,@r15

and not:

cmp #0,r15

Because, at this point, r15 has the pointer (or address to
menu_stack[menu_i].item, after incrementing it (by add and mov).

Anyway the bug is here.

> There may be a bug lurking elsewhere, but I don't think that's it.
> 
> Does your code work correctly when compiled on your PC?
> 
> Are there any mspgcc developers out there with any feedback for Pedro?
> 
> - jake.
> 
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program.
> SourceForge.net hosts over 70,000 Open Source Projects.
> See the people who have HELPED US provide better services:
> Click here: http://sourceforge.net/supporters.php
> _______________________________________________
> Mspgcc-users mailing list
> Mspgcc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
> 

-- 
José Roberto B. de A. Monteiro
Autsens Ind. e Com. de Equip. Eletr. Ltda.
R. Jesuíno de Arruda, 3040 -- Centro
13560-060 -- São Carlos -- SP
Tel. (16) 274 8499
FAX: (16) 271 4571

Reply via email to