This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

simulation doesn't work

Hi all,
I try to use the simulator with a code that contains struct or union, but it doesn't seem to see members. Here is an example code:

struct chuf
{
unsigned char hi;
unsigned char lo;
};

union
{
struct chuf chi;
unsigned int both;
} buf;


void main(void)
{
buf.chi.hi =5;
buf.chi.lo =1;
buf.both =0x1122;
while (buf.both) buf.both>>=1;
}

When I try to see something like buf.both, it shows error 10. By the way, where can one see the list of simulator errors? When I look for just buf, it shows the first byte of this union. At the same time, within the memory it seems to work right.
Can anything be done about it?
Thanks,
Michael.

Parents
  • Perhaps it would help if the interleaved 'C'/Assembler listing were more accessible?

    I'm not sure what you mean. The .SRC file includes both the C and generated assembly code interleaved.

    How do other compilers cope with source-level debug for inline assembler?

    This is really implementation-defined. However, I guess that other C compilers (that generate assembler output instead of .OBJ output) insert assembler directives that say to the linker, "Hey, the following lines of assembly refer to line number xxx in the C source file yyy.c"

    However, if you go start hacking on the assembler output, I would think that it's possible to introduce subtle synchronization errors between the assembler and C source.

    Jon

Reply
  • Perhaps it would help if the interleaved 'C'/Assembler listing were more accessible?

    I'm not sure what you mean. The .SRC file includes both the C and generated assembly code interleaved.

    How do other compilers cope with source-level debug for inline assembler?

    This is really implementation-defined. However, I guess that other C compilers (that generate assembler output instead of .OBJ output) insert assembler directives that say to the linker, "Hey, the following lines of assembly refer to line number xxx in the C source file yyy.c"

    However, if you go start hacking on the assembler output, I would think that it's possible to introduce subtle synchronization errors between the assembler and C source.

    Jon

Children
  • Andy:
    "Perhaps it would help if the interleaved 'C'/Assembler listing were more accessible?"

    Jon:
    "I'm not sure what you mean. The .SRC file includes both the C and generated assembly code interleaved"

    Sorry, I was thinking of the assembler listing produced by the CODE directive. Oops!

    However, I note that the .SRC file duplicates the assembler code between the ASM and ENDASM - once as a comment (representing the 'C' source) and again as "real" assembler; eg,

    ;       #pragma ASM
    ; 
          
    ;       EXTRN CODE (m_main)
          EXTRN CODE (m_main)
    ; 
          
    ;       MOV     A,#LOW( m_main )              ;
          MOV       A,#LOW( m_main )              ;
    ;       MOV     wait_return_address_low,Acc     ;
          MOV       wait_return_address_low,Acc     ;
    ;       MOV     A,#HIGH( m_main )                 ;
          MOV       A,#HIGH( m_main )                 ;
    
    This seems unnecessary & rather confusing.