Dear all, I am using the Keil 5.23 and running simulation for the STM32F103ZE
I am using optimization Level 0 (-O0)
In C, I have declared two variables i j i = 0x12345678 j = 0x87654321
then I have 2 instructions in C
dummy = i + j;
dummy = i - j;
When I switch to Disassembly and looking to the disassembly code,
the register value
R2 = 0x12345678; R3 = 0x87654321; before executing the ADD r2,r2,r3 the XPSR shows
N = 1, Z = 0, C = 1, V = 0, Q = 0, T = 1; After the ADD instruction, results remains the same.. However, from the addition, there should be NO Carry after the addition, why the status of the xPSR not updated ?
It would be grateful if I can get any help on that.. Thanks, Yours FOX
Chi Hang,
> I still cannot understand why the compiler only translate the i + j differently in comparison to other & | ^ and - commands. <
I believe that, you already know that your above assumption is incorrect. This is what I have tried to convince you.
And I also believe that, from Westonsupermare Pier's 15-Jun-2017 13:34 GMT post, you (and me) already know that compiler chooses instructions based on the Source Code Context. When the demo source code is so short, compiler just chooses instructions whatever it likes.
Please don't be disappointed with the atmosphere of this forum, you did get the help you need (not from me) from Westonsupermare Pier's valuable post.
Many Thanks for Westonsupermare Pier.
> You're using the word testing as if you're trying to identify a fault. <
I am not a native English speaker. I used the word testing, because A. I believe that OP's original assumption is incorrect. B. When I get a new device, and don't know how to use it, I will do some testing to figure it out. This doesn't mean it is a faulty device.
Sorry for any misunderstanding caused.
I also redo your latest testing, got the same result as yours. ( I am not using Keil 5.23. )
Chiu, John Linq Zhao, John Linq Chao, John Linq
Dear John,
Thanks for input and I admit that my original assumption is incorrect. Your code gives direction to me and helps alot.
My sincere thanks to you..
I am sure I did get help from this forum which allows collaborative inputs.
Thanks, Yours WU, Chi Hang