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
  • You explain me the difference between .obj and .src files.

    Actually, I explained why you can't see C structures when you compile the C file and generate assembly source. I guess I wasn't very clear on that point. Maybe this makes more sense.

    Rule 1. The Keil A51 Assembler does not have a struct data type. Therefore, structures in assembly must be implemented as an array of bytes. When you use the debugger to view these assembly structures, only the first byte will be displayed.

    This applies EVEN IF you start with a C file and compile it using the SRC directive. The output from the C compiler is an assembler source file (.SRC) which you must then assemble using the A51 Assembler. And, Rule 1 applies.

    The assembler works this way by design.

    Jon

Reply
  • You explain me the difference between .obj and .src files.

    Actually, I explained why you can't see C structures when you compile the C file and generate assembly source. I guess I wasn't very clear on that point. Maybe this makes more sense.

    Rule 1. The Keil A51 Assembler does not have a struct data type. Therefore, structures in assembly must be implemented as an array of bytes. When you use the debugger to view these assembly structures, only the first byte will be displayed.

    This applies EVEN IF you start with a C file and compile it using the SRC directive. The output from the C compiler is an assembler source file (.SRC) which you must then assemble using the A51 Assembler. And, Rule 1 applies.

    The assembler works this way by design.

    Jon

Children
No data