cancel
Showing results for 
Search instead for 
Did you mean: 

conversion of c to assembly

prabk4u2004
Associate II
Posted on February 04, 2015 at 11:10

Dear sir/mam

As i am working on data acquisition project , i am facing the timing problem and i am not able to access complete data from the simulator for the transmission speed of 10 KHz  and above , data is missing frequently , so i am planning to go for Assembly language instead of C-programming, i need your help regarding this, i will update the developed code plz have a look at it

i want the below for loop to be converted to ASM, i kindly request you to help me regarding this issue at the earliest

for(i=0;i<=23;i++)   // inner for loop to make a byte

{

signature2_byte=signature2_byte<<1;

signature2_byte=signature2_byte + signature_bit_array2[l];

l++;

}

regards

8 REPLIES 8
stm322399
Senior
Posted on February 04, 2015 at 11:32

Can you post the resulting assembly compiled for this part of the code ? Generally compiler are not very bad, excepted for anticipating loads. I recommend to understand what the compiler does and then try to remove bottlenecks.

Did you try a better algorithm ? if signature_byte_array2 only hold ones and zero, it could make sense to pre-compute the signature for every combination of 8 bits from signature_byte_array2 and your loop could be reduced to 3 iterations ... well, no iteration at all because it can be un-rolled.

--

laurent

prabk4u2004
Associate II
Posted on February 04, 2015 at 12:11

dear gonzalez

I thank you and appreciate for your immediate response , i will explain you the requirement and i will update the developed code plz have a look at attach file,

what i am doing on my code is i am receiving the pulse form port on clk interrupt , i will collect all the pulses like 0s and 1s to form a byte , this will continue till i receive 128 bytes along with the SOF . the code i working from 1khz to 9 khz after that like 10 khz etc the data is missing and i am not able to match the SOF with the received pulse , and the pulse are missing.

________________

Attachments :

3_TDAS_ARM_USART.rar : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I03v&d=%2Fa%2F0X0000000bSw%2FG3ym0ZldZSkflTsCU6bmMp3vsvHwtNLyqKVoln75q0w&asPdf=false
Posted on February 04, 2015 at 14:41

So IRNSS data.

You could unroll it.

Code could do with a substantial rethink, perhaps holding the incoming bit stream in a 32-bit word, and masking it. Holding everything in bits, and then mapping it back and forth seems a bit amateurish and slow.

Converting this one routine to assembler might help speed slightly, you'd do much better if you fixed the algorithm so there was less wasted effort.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ivani
Associate II
Posted on February 04, 2015 at 21:34

Just another thought - you may consider using the bit-band region for storing the bit array. Then the data could be accessed at word basis from the SRAM area and vice versa without any conversion.

prabk4u2004
Associate II
Posted on February 05, 2015 at 06:13

Thank you for the response and now what i should do,if you don't mine can you please explain briefly and i am struggling in frequency like above 10khz is not working give me some idea. 

prabk4u2004
Associate II
Posted on February 05, 2015 at 06:39

dear clive

I thank you for your response ,As you said i have to rethink the different algorithm, i need another help from your end Mr.clive as you said to collect all the bit and then compare, i have totally 128 bytes how to collect all the 1024 bits and compare with the SOF, in some case there will be an bit shift in order to match the Frame i need to left shift the bit frame , i kindly request you suggest me with some technique, kindly look in to the attachment i have uploaded my code

regards

sowmya

________________

Attachments :

3_TDAS_ARM_USART.rar : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I03q&d=%2Fa%2F0X0000000bSv%2FvTxB0yACFWn01LdUanOY.RdyViHB13u0z_hvZaWYBys&asPdf=false
prabk4u2004
Associate II
Posted on February 07, 2015 at 06:53

Dear clive

As you said to collect all the bit and then compare, i have totally 128 bytes how to collect all the 1024  bits  and compare with the SOF, in some case there will be an bit shift in order to match the Frame i need to left shift the bit frame , i kindly request you suggest me with some technique

Posted on February 07, 2015 at 13:29

Like I said you need to do this differently, where you shift bits in a register, search for sync when you're out-of-sync, and confirm the  framing sync/preamble when you are in sync.

Use a state machine. As you receive each bit, shift it into a register (the processor uses 32-bit ones, so that's pretty efficient), as you accumulate enough bits for a byte write that to your buffer, check the sync word at your byte/frame boundary, and if you are not in sync then check your sync word at each bit shift, by masking of the relevant 24-bits and comparing them.

If you do this on the fly, the achievable throughput will be significantly higher than trying to assemble and handle dozens of bits/bytes during a single bit time/interval.

I don't think bit banding is useful here.

Review also the concept of local/auto variables, static variables in functions, and other applications processing bit streams.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..