-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Improve reading ADC result #345
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me. As analyzed in #344, the original problem is a gcc missed optimization, but since we can't easily fix that, making this change here to fix at least this particular instance of this problem seems reasonable to me. The new code is probably even easier to read than the old code, so that's a small bonus.
One thing I'd like to see improved is the commit message. It now says "Improve", but that suggests that the reading itself is maybe somehow better or more accurate. Also, the detailed commit message has no mention of the improved generated assembly, or gcc failing to optimize this in some cases, which I think would be valuable info for anyone that comes back to this commit in the future trying to figure out why this changed :-)
I verified that this indeed improves the generated assembly using some of the examples from the linked issue.
Okay, I edited the commit message to give more details. |
Message looks good, but you now only edited the PR description, not the commit message. Can you also edit the commit message (if you're unsure how, you can do this using |
7.3.0-atmel3.6.1-arduino7 gcc fails to optimize separate reading from ADCL and ADCH. It produces additionally three eor commands or in some cases two mov commands in the assembly code (see discussion arduino#344). These commands swap register contents before store them to data area. So they are completely unnecessary. Reading ADC result with ADC macro fixes it and gcc generates the right code..
Oh yeah, sorry, my bad, did this with the same message as well. |
from: arduino/ArduinoCore-avr#345 7.3.0-atmel3.6.1-arduino7 gcc fails to optimize separate reading from ADCL and ADCH. It produces additionally three eor commands or in some cases two mov commands in the assembly code. These commands swap register contents before store them to data area. So they are completely unnecessary. Reading ADC result with ADC macro fixes it and gcc generates the right code..
from: arduino/ArduinoCore-avr#345 7.3.0-atmel3.6.1-arduino7 gcc fails to optimize separate reading from ADCL and ADCH. It produces additionally three eor commands or in some cases two mov commands in the assembly code. These commands swap register contents before store them to data area. So they are completely unnecessary. Reading ADC result with ADC macro fixes it and gcc generates the right code..
7.3.0-atmel3.6.1-arduino7 gcc fails to optimize separate reading from ADCL and ADCH. It produces additionally three
eor
commands or in some cases twomov
commands in the assembly code (see discussion #344). These commands swap register contents before store them to data area. So they are completely unnecessary. Reading ADC result withADC
macro fixes it and gcc generates the right code.