-
Notifications
You must be signed in to change notification settings - Fork 8
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
macros for using factory calibration values #3
Comments
It seems like even with the latest SDCC nightly snapshot (v4.0.2 #11715) it still generates much less efficient code: With the current code:
... the following assembly is generated (2 words, 5 cycles):
With the new code:
... it still generates this less efficient (larger/slower) code (5 words + 12 words for __gptrget, 6 cycles + 15 cycles for __gptrget):
Were you expecting something more efficient to be generated? Granted, depending on the program, the 12 word __gptrget method may already be included, but even so, it is still larger/slower than the existing code. The most likely place for this factory calibration code to be used is the _sdcc_external_startup method, which should really be kept to the bare minimum anyway. |
Ok, I may have found a better solution: This code:
... generates the same efficient assembly (2 words, 5 cycles):
|
Fixed with: 451f449 |
But SDCC would have to assume that the called function might change p or a flag. SDCC could thus generate better code when it knows it is a read from code memory that would not do such things. |
SDCC can generate the best code for simple assignment:
Will give the same code as your function pointer use above, but now SDCC can keep p in use at the point of the read (since it knows there will be a ret k, which does not change registers, at the called location). |
Well, the called function does change a, so that pars is ok. It doesn't change p, but because the normal place to initialize this code (i.e. |
I still can't get this to generate good code. Your specific example does generate efficient code, but the address isn't correct. I'm not sure where 0x87ed comes from, but SDCC changes that to 0x07ed for some reason and generates this:
That might work for the PFS154, but not for other devices. Whey I try to replace the 0x87ed with a real address (i.e. 0x0bed), SDCC reverts back to using the inefficient Can you explain where the 0x87ed comes from, and why SDCC is converting that to 0x07ed, and why using a real address doesn't generate the efficient code? |
Now that SDCC generates efficient code for assignment from an address that is just a cast integer literal to a __sfr, IMO the asm macros for factory clibration aren't needed anymore.
Inline asm tends to interfere with optimizations, so for larger functions containing a use of factory calibration values, the assignment is likely to result in more efficient code being generated by SDCC.
The text was updated successfully, but these errors were encountered: