EmbeddedRelated.com
Forums

New _SWAP_BYTES intrinsic function in IAR V1.26B

Started by Ian Okey November 22, 2002
The readme file for the new version 1.26B of the IAR compiler talks about a

new intrinsic function _SWAP_BYTES.

<quote>
New features

A new intrinsic function _SWAP_BYTES has been implemented in the compiler. 
This function executes the SWPB instruction.

unsigned short _SWAP_BYTES(unsigned short dst);

</quote>

I thought that I would try it out.  Result = disappointment.

The function prototype does not appear in my copy of IN430.H (presumably it 
should have been updated by the installation of the new version), and XLINK 
throws an error E46 (undefined external).

Has anyone managed to use this function or have IAR messed up this release?

Awaiting a response from IAR support.

Ian

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?pageatures/featuredemail


Beginning Microcontrollers with the MSP430

providing 'a' is 16bits unsigned
normal compilers will do swap bytes for:
(a<<8) | (a>>8)

~d


--- In msp430@y..., "Ian Okey" <ian_okey@h...> wrote:
> The readme file for the new version 1.26B of the
IAR compiler talks 
about a 
> new intrinsic function _SWAP_BYTES.
> 
> <quote>
> New features
> 
> A new intrinsic function _SWAP_BYTES has been implemented in the 
compiler. 
> This function executes the SWPB instruction.
> 
> unsigned short _SWAP_BYTES(unsigned short dst);
> 
> </quote>
> 
> I thought that I would try it out.  Result = disappointment.
> 
> The function prototype does not appear in my copy of IN430.H 
(presumably it 
> should have been updated by the installation of
the new version), and 
XLINK 
> throws an error E46 (undefined external).
> 
> Has anyone managed to use this function or have IAR messed up this 
release?
> 
> Awaiting a response from IAR support.
> 
> Ian
> 
> 
_________________________________________________________________
> Add photos to your messages with MSN 8. Get 2
months FREE*. 
> http://join.msn.com/?pageatures/featuredemail


> providing 'a' is 16bits unsigned
> normal compilers will do swap bytes for:
> (a<<8) | (a>>8)

I don't think that's the point here ...........
Ian's talking about the presence/absence of an intrinsic






On Sat, Nov 23, 2002 at 02:36:45PM +1100, Kris De Vos wrote:
> > providing 'a' is 16bits unsigned
> > normal compilers will do swap bytes for:
> > (a<<8) | (a>>8)
> 
> I don't think that's the point here ...........
> Ian's talking about the presence/absence of an intrinsic

I think you *missed* the point - given the code in question, the compiler
should produce a swpb instruction, so there's no need for an
"intrinsic".

-- 
Clyde Stubbs                     |            HI-TECH Software
Email: clyde@clyd...          |          Phone            Fax
WWW:   http://www.htsoft.com/    | USA: (408) 490 2885  (408) 490 2885
PGP:   finger clyde@clyd...   | AUS: +61 7 3552 7777 +61 7 3552 7778
---
HI-TECH C: compiling the real world.

At 02:30 PM 11/22/2002 +0000, diwilru wrote:
>providing 'a' is 16bits unsigned
>normal compilers will do swap bytes for:
>(a<<8) | (a>>8)
>
>~d

hey, that's pretty neat. I will add it to the compiler.


// richard <http://www.imagecraft.com> 
<http://www.dragonsgate.net/mailman/listinfo>
On-line orders, support, and listservers available on web site.
[ For technical support on ImageCraft products, please include all previous 
replies in your msgs. ] 


At 08:26 PM 11/22/2002 -0800, Richard wrote:
>At 02:30 PM 11/22/2002 +0000, diwilru wrote:
> >providing 'a' is 16bits unsigned
> >normal compilers will do swap bytes for:
> >(a<<8) | (a>>8)
> >
> >~d
>
>hey, that's pretty neat. I will add it to the compiler.

Hey pretty good eh?


FILE: swapb.c
(0001) unsigned x;
(0002) main()
(0003)  {
(0004)  unsigned a = 0xAAFF;
_main:
   b                    --> R5
   a                    --> R4
     306C 4034 AAFF              mov     #0xAAFF,R4
(0005)
(0006)  unsigned b = (a << 8) | (a >> 8);
     3070 4405           mov     R4,R5
     3072 1085           swpB    R5
(0007)
(0008)  a = (a << 8) | (a >> 8);
     3074 1084           swpB    R4
(0009)
(0010)  x = (x << 8) | (x >> 8);
     3076 1090 D188              swpB    0200
(0011)  }



// richard <http://www.imagecraft.com> 
<http://www.dragonsgate.net/mailman/listinfo>
On-line orders, support, and listservers available on web site.
[ For technical support on ImageCraft products, please include all previous 
replies in your msgs. ] 


Hey Clyde, didn't know you were on this forum, long time no talk ...
(Are you looking into an MSP430 tool as well ?)

Anyway, looks like we're gonna go get into useless trivia here :

Ian posted his dissapointment with the fact that IAR's EW430 - V1.26B (
despite the claim it's there ) intrinsics
header file <in430.h> didn't have the SWAP byte intrinsic
included......
(I haven't purchased another SUA, so I'm still using V1.26A, well
actually - V1.24A most of the time), so I can't help.....

Whether "other" compilers (even EW430 itself) generate a byte swap
with the C code supplied (which is bleeding obvious) 
is *completely irrelevant*.
I don't think I *missed* the point at all, I think the whole thread should
be visited first.........
There are many intrinsics that are not necessary, but they make C programming
easier and more accessible for newcomers......
I think Ian Okey's point is a salient one, and further seeks if other
people found the intrinsic missing as well.
THAT WAS IAN'S QUESTION......


BTW : IAR will generate a swap even when merely stating :
a = (unsigned char) (a>>8);
Furthermore, it depends on where the UINT "a" is located.
If it's on the stack frame as an auto var, and not in a register - then the
C code will not work in generating a mere
"swap" instruction .........


B rgds
Kris


  ----- Original Message ----- 
  From: Clyde Stubbs 
  To: msp430@msp4... 
  Sent: Saturday, November 23, 2002 3:12 PM
  Subject: Re: [msp430] Re: New _SWAP_BYTES intrinsic function in IAR V1.26B


  On Sat, Nov 23, 2002 at 02:36:45PM +1100, Kris De Vos wrote:
  > > providing 'a' is 16bits unsigned
  > > normal compilers will do swap bytes for:
  > > (a<<8) | (a>>8)
  > 
  > I don't think that's the point here ...........
  > Ian's talking about the presence/absence of an intrinsic

  I think you *missed* the point - given the code in question, the compiler
  should produce a swpb instruction, so there's no need for an
"intrinsic".

  -- 
  Clyde Stubbs                     |            HI-TECH Software
  Email: clyde@clyd...          |          Phone            Fax
  WWW:   http://www.htsoft.com/    | USA: (408) 490 2885  (408) 490 2885
  PGP:   finger clyde@clyd...   | AUS: +61 7 3552 7777 +61 7 3552 7778
  ---
  HI-TECH C: compiling the real world.

  .



   






Richard,
just look at the gcc port sources. It has already lots of features 
implemented (especially interesting peepholes).
If you've got questions - ask :)

~d


--- In msp430@y..., "Richard F. Man" <richard@i...> wrote:
> At 08:26 PM 11/22/2002 -0800, Richard wrote:
> >At 02:30 PM 11/22/2002 +0000, diwilru wrote:
> > >providing 'a' is 16bits unsigned
> > >normal compilers will do swap bytes for:
> > >(a<<8) | (a>>8)
> > >
> > >~d
> >
> >hey, that's pretty neat. I will add it to the compiler.
> 
> Hey pretty good eh?
> 
> 
> FILE: swapb.c
> (0001) unsigned x;
> (0002) main()
> (0003)  {
> (0004)  unsigned a = 0xAAFF;
> _main:
>    b                    --> R5
>    a                    --> R4
>      306C 4034 AAFF              mov     #0xAAFF,R4
> (0005)
> (0006)  unsigned b = (a << 8) | (a >> 8);
>      3070 4405           mov     R4,R5
>      3072 1085           swpB    R5
> (0007)
> (0008)  a = (a << 8) | (a >> 8);
>      3074 1084           swpB    R4
> (0009)
> (0010)  x = (x << 8) | (x >> 8);
>      3076 1090 D188              swpB    0200
> (0011)  }
> 
> 
> 
> // richard <http://www.imagecraft.com> 
> <http://www.dragonsgate.net/mailman/listinfo>
> On-line orders, support, and listservers available on web site.
> [ For technical support on ImageCraft products, please include all 
previous 
> replies in your msgs. ]


At 09:13 AM 11/23/2002 +0000, you wrote:
>Richard,
>just look at the gcc port sources. It has already lots of features
>implemented (especially interesting peepholes).
>If you've got questions - ask :)
>
>~d

Sure, why don't you just email me the .md file :-)


// richard <http://www.imagecraft.com> 
<http://www.dragonsgate.net/mailman/listinfo>
On-line orders, support, and listservers available on web site.
[ For technical support on ImageCraft products, please include all previous 
replies in your msgs. ] 


> 
> BTW : IAR will generate a swap even when merely
stating :
> a = (unsigned char) (a>>8);
> Furthermore, it depends on where the UINT "a" is located.
> If it's on the stack frame as an auto var, and not in a register - 
then the C code will not work in generating a mere
> "swap" instruction .........

Are
swbp @Rn
or
swpb &A
or
swpb X(Rn)

incortect? What's the problem with auto vars in a such 'rotate' 
instruction?




Richard,
most recent (and actually all of them) .md file is available on the 
web in mspgcc.sf.net

~d


>   ----- Original Message ----- 
>   From: Clyde Stubbs 
>   To: msp430@y... 
>   Sent: Saturday, November 23, 2002 3:12 PM
>   Subject: Re: [msp430] Re: New _SWAP_BYTES intrinsic function 
in IAR V1.26B
> 
> 
>   On Sat, Nov 23, 2002 at 02:36:45PM +1100, Kris De Vos wrote:
>   > > providing 'a' is 16bits unsigned
>   > > normal compilers will do swap bytes for:
>   > > (a<<8) | (a>>8)
>   > 
>   > I don't think that's the point here ...........
>   > Ian's talking about the presence/absence of an intrinsic
> 
>   I think you *missed* the point - given the code in question, the 
compiler
>   should produce a swpb instruction, so
there's no need for an 
"intrinsic".
> 
>   -- 
>   Clyde Stubbs                     |            HI-TECH Software
>   Email: clyde@h...          |          Phone            Fax
>   WWW:   http://www.htsoft.com/    | USA: (408) 490 2885  
(408) 490 2885
>   PGP:   finger clyde@h...   | AUS: +61 7 3552
7777 +61 7 3552 
7778
>   
---
>   HI-TECH C: compiling the real world.
> 
>   To unsubscribe from the msp430 group, send an email to:
>   msp430-unsubscribe@e...
> 
> 
> 
>   Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service. 
> 
> 
> 
>