#228 Volatile Direct Pointer not optimized

open
nobody
None
5
2008-02-01
2007-12-28
Anonymous
No

Accessing memory using a construct like
(* (volatile xdata TestStruct *)0xF000).Var1
(where TestStruct is a struct) generates a load of unnecessary assembler instructions if another as the first variable is accessed.
mov r2,#0x00
mov r3,#0xF0
mov dpl,r2
mov dph,r3
inc dptr
mov a,#0x04
movx @dptr,a
instead of
mov dptr,#0xF001
mov a,#0x03
movx @dptr,a

Please see the attached test file.

Discussion

  • Source to reproduce.

     
    Attachments
  • Johann Glaser
    Johann Glaser
    2007-12-28

    Logged In: YES
    user_id=14698
    Originator: NO

    Oops, forgot to login before submitting the bug.

     
  • Maarten Brock
    Maarten Brock
    2008-02-01

    • labels: 841812 -->
     
  • Maarten Brock
    Maarten Brock
    2008-02-01

    Logged In: YES
    user_id=888171
    Originator: NO

    Apparently the result differs whether the struct is volatile or not. But this is not a result of the peephole optimizer. Rather the '+' operator is not optimized in the ast.

    This is no bug, because the generated code works perfectly though suboptimal. Therefor I move this to the feature requests.