Can't add a question about C behavior | Cypress Semiconductor
Can't add a question about C behavior
I tried to add a question about weird behavior I'm seeing from my C code, but the "spam filter" blocked the post.
I guess it didn't like the code snippet in the body of the post. How can I ask my question?
Edit: Maybe I can edit the post enough to ask my question without including code...?
This is for a project that interfaces with an 8-bit CPU by emulating RAM/ROM.
It works, under some circumstances. There is an if statement for the ROM emulation area (based on what range is being addressed), and the other branch is for the read/write buffer area. Handling the ROM area first is to make it fast enough to execute machine language from, directly. That works, too, sort-of.
The catches are:
1. There is a Status Read() that already assures that the range addessed will be either ROM or buffer; the ROM part is if the page number is below 12. The second branch should work with just an else, and SHOULD be faster that way, but it actually causes the ROM part to fail if I don't use an else if in the buffer part.
2. I have a function that has a switch statement to do other processing based on a command passed to the last address of the buffer. Right now there is one command in there. If I add a second case to the switch statement, with some calls in that block, that will cause the "ROM" reads to become unreliable - some bytes are read correctly, and some are not.
Why should the main loop care how many sections are in the function when I'm not passing any commands or even addressing the section that might cause the function to be called? Why is an else if, with an already known area in the if, faster than a plain else?
Please help. This is really making me crazy!
Edit again: added the main loop and function in the attached text file. Hopefully you can see it. This is the current code that works... until I uncomment the other lines in req = 2.