Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly Language > Looking for a c...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 4902 of 5181
Post > Topic >>

Looking for a code transformation

by Tim Frink <plfriko@[EMAIL PROTECTED] > Mar 9, 2008 at 04:52 PM

Hi,

I want to reduce code size of my DSP code. The Infineon processor I'm
using sup****ts two different types of instructions, a 16 and a 32 bit
version. There are no equivalent 16bit instructions for all 32bit
instruction and the 16bit instructions are obviously more constrained
in terms of their operands. So, for example for jumps, the maximal
displacement can be 8bit large while the 32bit jumps sup****t up to
16bit. For my question, I however assume that the size of the displacement
operand is not an issue.

What I want to do in particular is the substitution of 32bit jumps
by equivalent 16bit jumps. This is a piece of assembly code I often
find in my program and I would like to optimize:

        move     d1, 10
        move     d2, 1000
        jge      d2, d1, target

So, the constants 10 and 1000 are stored into registers d1 and d2
and finally the jump (jump greater/equal) is taken to "target" if
the value of register d2 >= d1.

To reduce code size, I'd like to replace this 32bit jump by a
16bit jump which is defined as:

	jz/jnz dX, target

So, whenever the value of register dX is zero (jz) or is not
zero (jnz), the branch is taken.

Now I'm wondering how the first code can be efficiently transformed
into an semantically equal code where jz/jnz is used. Obviously,
jz/jnz has a slightly different meaning compared to jge but I hope
that there is a way to transform the second code without using too
many additional instructions (which would undo the code size 
reduction I achieve with the jump instruction replacement).

A possible solution (but not applicable due to an additional code size
increase) could look like:

   move d1, 10
   move d2, 1000    
   sub  d3, d2, d1
   ge   d4, d2, 0  # d4 becomes 1 if d2 >= 0
   jnz  d4, target

Do you see any better solution. It's fully OK if you give an
example in any pseudo assembler code.

Thank you.
Tim
 




 5 Posts in Topic:
Looking for a code transformation
Tim Frink <plfriko@[EM  2008-03-09 16:52:05 
Re: Looking for a code transformation
Robert Redelmeier <red  2008-03-09 21:46:43 
Re: Looking for a code transformation
Herbert Kleebauer <kle  2008-03-10 10:15:54 
Re: Looking for a code transformation
Terence <tbwright@[EMA  2008-03-14 19:53:43 
Re: Looking for a code transformation
Tim Frink <plfriko@[EM  2008-03-10 18:55:20 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 16:09:59 CST 2008.