Probably another misunderstanding on my part..
Jack Buffington
Posts: 115
I'm continuing on with my project and am hitting some difficulty again. I am using inline assembly since I am short on the number of cycles available and the compiler isn't generating tight enough code. That's OK though I can work in assembly.
I have a bit of code that is supposed to work like a serial port running at about 1.8 MHz. Here is the assembly that I am giving it:
The compiled version of this looks like this with what the code should be in comments to its right:
For some reason, it is using r7 as both temp3 and outLong, which doesn't do what I want. Is there a way to force it to honor the difference between these variables? I tried sticking in volatile after __asm__ as suggested by this page https://sites.google.com/site/propellergcc/documentation/tutorials/inline-asm-basics but that didn't do the trick.
Any ideas?
I have a bit of code that is supposed to work like a serial port running at about 1.8 MHz. Here is the assembly that I am giving it:
__asm__ volatile( // a bunch of other code here but I am just showing the last bit for the sake of simplicity // It is pretty much a bunch of repetitions of the snippet shown below. "waitcnt %[temp1],%[waitDelay]\n\t" // bit 7 "mov %[temp3],INA\n\t" "and %[temp3],%[theBit]\n\t" // clear everything but the bit that I am looking at "shr %[outLong],#1\n\t" "add %[outLong],%[temp3]\n\t" : //outputs [outLong] "=r" (outLong) : //inputs [temp1] "r" (temp1), [theBit] "r" (theBit), [LED] "r" (LED), [waitDelay] "r" (waitDelay), [zero] "r" (zero), [temp3] "r" (temp3) );
The compiled version of this looks like this with what the code should be in comments to its right:
69 00dc 0000BCF8 waitcnt r6,r2 // waitcnt temp1,waitDelay 70 00e0 0000BCA0 mov r7,INA // mov temp3,INA 71 00e4 0000BC60 and r7,r5 // and temp3,theBit 72 00e8 0100FC28 shr r7,#1 // shr outLong,#1 73 00ec 0000BC80 add r7,r7 // add outLong,temp3
For some reason, it is using r7 as both temp3 and outLong, which doesn't do what I want. Is there a way to force it to honor the difference between these variables? I tried sticking in volatile after __asm__ as suggested by this page https://sites.google.com/site/propellergcc/documentation/tutorials/inline-asm-basics but that didn't do the trick.
Any ideas?
Comments
For those of you who might be reading this in the future, I changed:
[outLong] "=r" (outLong)
to
[outLong] "&=r" (outLong)
Now, I need to dive into the documentation to really understand why this did the trick.
Here is the assembly code that is generated:
It doesn't appear to be doing the correct thing. It is doing some optimization here, which is good because what I have to do in C isn't optimal but the line:
test r7,#0x1 wz
Is comparing what was copied from INA to the value 1, which isn't what I want. In my case, I really need to compare to 1<<6, 1<<7, or 1<<8 to get correct answers.
Is there a setting or keyword that I can use (short of setting things to -O0) to keep the compiler from being so hyperactive about its optimization that it loses sight of what I am asking it to do?
No hurry on this one though, it was relatively easy to drop to assembly for this one.
...Though this one ended up not having anything to do with the compiler. I can't believe that I have never run across this one before.
Do any of you have any ideas about this one?
Update....
I just built a new project from scratch that only has the toggle cog and the TV and graphics stuff. This project isn't allowing me to run both things at the same time as well.
Here is the code for that project:
The compiler settings are:
EEPROM
C
CMM
-O1 Mixed
I have also tried tucking the toggle cog stuff into the graphics demo program. The graphics portion runs but the toggle won't. If I take all of the graphics and TV stuff out of the project manager and put it right back in then the LED blinks but there are no graphics....