Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi folks,

   

I'm trying to embed some inline assembly in my project to work around areas where I can't get the compiler and optimizer to do what I want.

   

I pulled the lst file for the main loop, and I can see a couple of places that I want to tweak, to save a few precious clock cycles. What has me confused is that the lst formatting looks like ARM assembly, but AN89610 (Code Optimization document for PSOC 4) says that PSOC 4 uses Thumb 2.

   

Is there a way to choose ARM or Thumb?

   

I modified the main loop portion of the lst code, and swapped it in within asm(" .... "); The result is a "Cannot represent THUMB_OFFSET relocation in this object file" error during build. There's a referenced .s file and line number, but I can't find the actual file. I'm guessing it's just temporary during the build process....? 

   

At this point, I'm getting almost the performance I need from my solution in C, but I have tried many variants, and only been able to find options that don't work. I do think I need the extra savings I can get from using assembly in the critical sections.

   

Thanks for the help,

   


Edit: I think I see the cause of the error: I missed that an array I'm using is represented as a label within the assembly block. I'll need to fix the assembly to correct address the array. I'm still rather confused about the ARM vs. Thumb stuff, though.

   

 

   

Paul

0 Likes
1 Solution
Anonymous
Not applicable

This almost works:

   

        asm(
            "ldr r3, [%[datawrite]]\n"  //Get address of data write function
            "mov    r2, #125\n"
            "str r2, [r3]\n"  //write data bus from r2
            :
            :   [addhigh] "l" (Pin_Address_High_PS),
                [addlow] "l" (Pin_Address_Low_PS),
                [datawrite] "l" (Pin_Data_DR),
                [dataread] "l" (Pin_Data_PS),
                [pinrw] "l" (CYREG_PRT0_PS),
                [buffer] "l" (buffer)
            );
 

   

It compiles, and builds, and programs, but it doesn't actually set the 125 value on the data bus. However, the resultant lst output does look pretty similar, so I think I'm close to getting this right.

   

On the other hand, one difference I observed between what's in the lst files and what will compile is f after the label of a forward jump. The generated assembly in the lst files had this, but it caused a compile failure when I used it in my code.

View solution in original post

0 Likes
15 Replies