We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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.
When assembler insertions are used in a C source file, it will not be compiled unless you turn on certain options for this file. In the file list, you click the file with the right mouse button and you have, among others, two options: Generate Assembler SRC File and Assemble SRC File. They should be turned on. I don't know the exact result of this action. It seems to me that assembler file is produced in any case, whether you use assembler insertions or not. But when these two options are turned on, you can use assembler insertions, but cannot use simulator to see structure or union members. When the are off, it's the opposite: you can see members, but you can't use assembler. Michael.
Jon Ward has explained what's happening. You didn't mention that you were going via Assembler in your original post - which is why I couldn't reproduce your problem!