-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compound conditional generates bad code #65
Comments
Branch locations are a little messed up in the It's actually a bit difficult to overcome. My approach was to generate code first, and print it out after generation is done. This requires a lot of extra housekeeping to track, and the modifications to do this are not small, really polluting the simplicity of c4. See #30 for a little more explanation of what is going on here. |
I moved the printout for sources/addresses to happen after parsing, and now get correct results: 73: while (*p != 0 && *p != '\n') ++p; Thanks. All is indeed well. BTW Getting the after-parse source listing only required adding 18 lines of code, and moving the existing print code from the next() routine to main(). |
I suppose it depends on what your goal is. I complicated things because I wanted |
int is defined as 32 bit here, not long long, but that is not related to the bug:
%c4 -s c4.c
73: while (*p != 0 && *p != '\n') ++p;
0xb6d4c2a4 IMM 0xb6d0b008
0xb6d4c2ac LI
0xb6d4c2b0 LC
0xb6d4c2b4 PSH
0xb6d4c2b8 IMM (nil)
0xb6d4c2c0 NE
0xb6d4c2c4 BZ 0xb6d4c2f0 <<-- This address is wrong for short ciruit op
0xb6d4c2cc IMM 0xb6d0b008
0xb6d4c2d4 LI
0xb6d4c2d8 LC
0xb6d4c2dc PSH
0xb6d4c2e0 IMM 0xa
0xb6d4c2e8 NE
0xb6d4c2ec BZ (nil)
0xb6d4c2f4 IMM 0xb6d0b008
0xb6d4c2fc PSH
0xb6d4c300 LI
0xb6d4c304 PSH
0xb6d4c308 IMM 0x1
0xb6d4c310 ADD
0xb6d4c314 SI
The text was updated successfully, but these errors were encountered: