EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Assembler Vs C-Compiler

Started by Tam July 10, 2003
Jonathan Kirwan wrote:

> On Thu, 17 Jul 2003 15:25:23 +0930, Al wrote:
> 
> 
>>As I said, looking at it I knew I could do better, that it could shrink 
>>further. There just seemed to be too many compares. Now when your 
>>compiler finds your revised solution everytime I'll take two. ;@}
Of 
>>course I don't expect a compiler to come up with the solution Jon
provided.
> 
> 
> Actually, Al, I think I can expect them to get there soon.
> 
> It just hit me, remembering something on a proof (or was it yet
> to be verified when I read it) from Bennett, I believe though it
> certainly could be bad memory operating here, who formally
> showed that first-order predicate logic is the same as point-set
> topology... and an insight has just arrived about how I might
> develop transforms which are topologically invariant on the
> important properties, yet quite dissimilar in the specific
> sequential logic.  Could be a totally bogus insight, but it's
> going to be an interesting week playing with this when I find
> that week to play.  Damn, it's going to be fun.  :)
> 
> Jon

YOU HAVE A STRANGE IDEA OF WHAT CONSTITUTES FUN ;@\, and people call me 
warped and twisted!!

Al


Beginning Microcontrollers with the MSP430

On Thu, 17 Jul 2003 17:10:59 +0930, Al wrote:

>Jonathan Kirwan wrote:
>
>> On Thu, 17 Jul 2003 15:25:23 +0930, Al wrote:
>> 
>> 
>>>As I said, looking at it I knew I could do better, that it could
shrink 
>>>further. There just seemed to be too many compares. Now when your 
>>>compiler finds your revised solution everytime I'll take two.
;@} Of 
>>>course I don't expect a compiler to come up with the solution
Jon provided.
>> 
>> 
>> Actually, Al, I think I can expect them to get there soon.
>> 
>> It just hit me, remembering something on a proof (or was it yet
>> to be verified when I read it) from Bennett, I believe though it
>> certainly could be bad memory operating here, who formally
>> showed that first-order predicate logic is the same as point-set
>> topology... and an insight has just arrived about how I might
>> develop transforms which are topologically invariant on the
>> important properties, yet quite dissimilar in the specific
>> sequential logic.  Could be a totally bogus insight, but it's
>> going to be an interesting week playing with this when I find
>> that week to play.  Damn, it's going to be fun.  :)
>> 
>> Jon
>
>YOU HAVE A STRANGE IDEA OF WHAT CONSTITUTES FUN ;@\, and people call me 
>warped and twisted!!
>
>Al

Hehe.  I just went to a dinner party with a group, tonight.  Got
back an hour ago.  At that party is a mathematician working on
M-theory ideas.  Guess what we spent the dinner time talking
about?  Tensors in various dimensions, tortions elements in
otherwise symmetric matrices, intrinsic and extrinsic
curvatures, rotational degrees of freedom, gauge degrees of
freedom (charge, EM, SU(2), etc.), and a fair mix of related
subjects from phase/gauge, Weyl and Goedel, and you name it.
When we left, my wife just noted to me that "You probably didn't
hear any of the discussion, but XXX thought you were cute and
funny."

Whatever that might mean.

Jon


Jonathan Kirwan wrote:

> On Thu, 17 Jul 2003 17:10:59 +0930, Al wrote:
> 
>>
>>YOU HAVE A STRANGE IDEA OF WHAT CONSTITUTES FUN ;@\, and people call me 
>>warped and twisted!!
>>
>>Al
> 
> 
> Hehe.  I just went to a dinner party with a group, tonight.  Got
> back an hour ago.  At that party is a mathematician working on
> M-theory ideas.  Guess what we spent the dinner time talking
> about?  Tensors in various dimensions, tortions elements in
> otherwise symmetric matrices, intrinsic and extrinsic
> curvatures, rotational degrees of freedom, gauge degrees of
> freedom (charge, EM, SU(2), etc.), and a fair mix of related
> subjects from phase/gauge, Weyl and Goedel, and you name it.
> When we left, my wife just noted to me that "You probably didn't
> hear any of the discussion, but XXX thought you were cute and
> funny."
> 
> Whatever that might mean.
> 
> Jon

I read the Lancet, NEJM, Nature, Physics, Scientific American, National 
Geographic, Circuit Cellar and Nuts and Volts, I willingly admit to only 
understanding the latter 3, but usually manage to glean at least a 
little insight from the others, and enjoy the reading anyway. I would 
never public admit to reading these, in public, and at dinner I'm more 
the National Enquirer type. :*{

Al


OK, as promised to Jonathan, here's the listing from ImageCraft
ICC430. The 
minor suboptimal code of moving "b" out of R14 is fixed. It will go
out in 
the next release. 42 bytes.

(0001)    unsigned int gcd (unsigned int a, unsigned int b)
(0002)    {
(0003)          if (a == 0 && b == 0)
_gcd:
   b                    --> R15
   a                    --> R14
     306C 930E           tst     R14
     306E 2004           jne     3078
     3070 930F           tst     R15
     3072 2002           jne     3078
(0004)              b= 1;
     3074 431F           mov     #1,R15
     3076 3C0E           jmp     3094
(0005)          else if (b == 0)
     3078 930F           tst     R15
     307A 2002           jne     3080
(0006)              b= a;
     307C 4E0F           mov     R14,R15
     307E 3C0A           jmp     3094
(0007)          else if (a != 0)
     3080 930E           tst     R14
     3082 2408           jeq     3094
     3084 3C05           jmp     3090
(0008)              while (a != b)
(0009)                  if (a < b)
     3086 9F0E           cmp     R15,R14
     3088 2C02           jc      308E
(0010)                      b -= a;
     308A 8E0F           sub     R14,R15
     308C 3C01           jmp     3090
(0011)                  else
(0012)                      a -= b;
     308E 8F0E           sub     R15,R14
     3090 9F0E           cmp     R15,R14
     3092 23F9           jne     3086
(0013)
(0014)      return b;
     3094 4130           ret

// richard <http://www.imagecraft.com> 
<http://www.dragonsgate.net/mailman/listinfo> 


On Thu, 17 Jul 2003 18:20:33 -0700, Richard wrote:

>OK, as promised to Jonathan, here's the
listing from ImageCraft ICC430. The 
>minor suboptimal code of moving "b" out of R14 is fixed. It will
go out in 
>the next release. 42 bytes.

Thanks much!  I'll take a look at these over the next few days.
It's always some fun trying to infer some of the mechanics of
the compilers from what they produce.  This isn't lot to go on,
but some things may shine through, anyway.

Thanks, again.  To you and the others posting outputs.

Jon


Hi Jon,

> >OK, as promised to Jonathan, here's the
listing from 
> ImageCraft ICC430. 
> >The
> >minor suboptimal code of moving "b" out of R14 is fixed. It 
> will go out in 
> >the next release. 42 bytes.
> 
> Thanks much!  I'll take a look at these over the next few 
> days. It's always some fun trying to infer some of the 
> mechanics of the compilers from what they produce.  This 
> isn't lot to go on, but some things may shine through, anyway.
> 
> Thanks, again.  To you and the others posting outputs.

We all pretty much generate identical code now.  I believe IAR will
generate identical code too, except it will use R12 & R14.

-- Paul.


Memfault Beyond the Launch