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
>>For sure I will be trying my best to read the ARM instruction set and the C tutorials to make my teaching better, but I am disappointed with the atmosphere of this forum.
Unfortunately we see the results of poor/ineffective teaching methods here a lot, so it is a point of frustration.
If a student comes here expecting us to do their homework from scratch the teacher has failed. Failed to provide them with the insight to do the work, and failed to teach basic problem solving and logical deduction, rather than just "ask the internet" or cut-n-paste some code together, they don't understand, hoping for a Shakespeare-Monkey event to occur.
I'm an EE with a BEng, on paper you are likely a lot more qualified, so I have higher expectations.
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 Westonsupermare Pier,
Thanks for your suggestion and that triggered me to have a really deeper understanding on those material I need to teach.
Honestly, paper qualification is not important to me. I would appreciate a person without any diploma or certificates but experienced on their field who can give me insight to solve problems.
Very appreciate your inputs.
Thanks, Yours WU, Chi Hang
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.
I would appreciate a person without any diploma or certificates but experienced on their field who can give me insight to solve problems.
You say that, but I don't really see you doing so. You've rather consistently been ignoring all the insight offered to you --- often in the same post in which you claim to have understood and accepted it.
So hopefully for the last time, let me put it strongly, but simply: you keep asking the wrong questions, because those questions are based on a colossal misunderstanding of what the job of a compiler is.
The job of the compiler is to generate machine code that does the work described by the actual source code. It's entirely up to the compiler to decide how it does that. Any and all hard expectations regarding the compiler's decisions are wrong. Of course you could run all kind of experiments to see what happens if you do "this", as opposed to "that", but that would be an exercise in futility, because the results will be largely unreliable.
And to top it off, said misunderstanding is quite typical of total greenhorns who have never used a high-level language before. That's what worries us so, as we see it manifest in a person who plans to teach this stuff.
Dear Hans-Bernhard Broeker,
Thanks for your statement of the job of the compiler and that would be informative to me.
Like a compiler, it is free for you to think if I am not appreciating the other's work, however, I truly appreciate all the information I got from here.