Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #59175

Re: Endian-swapping word ( was MD4 in Forth? )

Subject Re: Endian-swapping word ( was MD4 in Forth? )
Newsgroups comp.lang.forth
References (2 earlier) <f0ed859a-e4fd-4a24-b0ef-d560708293e3@googlegroups.com> <b2afbd94-5eb5-4aa6-8c90-f0af2d800c7a@googlegroups.com> <dfc78f18-eb56-4db7-ae22-11a1026b47b7@googlegroups.com> <ce2c2acb-b2b6-44ef-818a-b8da89beb61a@googlegroups.com> <f4b5a220-9bba-4877-a261-621665224af7@googlegroups.com>
From David Schultz <abuse@127.0.0.1>
Date 2017-05-13 09:44 -0500
Message-ID <Wq-dnRxRiqpDhorEnZ2dnUU7-RPNnZ2d@earthlink.com> (permalink)

Show all headers | View raw


On 05/12/2017 10:36 AM, Howerd wrote:
> Something that came out of writing the MD4 code : I think Forth should have an Endian-swapping word as standard ( as an extension ).
> : >32<  ( u -- u )   ... ; \ converts $11223344 to $44332211
> 
> This would avoid the _system_ having to know which Endianness it is, and place the responsibility on the application programmer. I know that this is the opposite direction compared to conventional wisdom.
> 
> i.e. BE@ has to know that if the system is Little Endian, it must reverse the byte order. If BE@ is standard, the application programmer has to know that the system is Little Endian and so use BE@ instead of @ ( or LE@).  
> 
> There is the 16 bit version in SwiftForth  >< , known by other names in other systems.
> 
> Suggestions for suitable names, anyone? 
> 

I used ><  to switch the order of a 32 bit word and ><H for a half word
on a 32 bit ARM eForth.

This brings up the problem of word size and portability. Should ><
always swap the order of just a 16 bit value or should it operate on the
natural size of an item on the stack?

I like the functions available in C via endian.h because they are
portable. Move the code between different systems and it still works.
But it does require a large set of functions.

-- 
David W. Schultz
http://home.earthlink.net/~david.schultz
"Life without stock is barely worth living..." - Anthony Bourdain

Back to comp.lang.forth | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

MD4 in Forth? Howerd <howerdo@yahoo.co.uk> - 2017-03-20 14:11 -0700
  Re: MD4 in Forth? Paul Rubin <no.email@nospam.invalid> - 2017-03-20 21:41 -0700
    Re: MD4 in Forth? mhx@iae.nl - 2017-03-20 23:02 -0700
      Re: MD4 in Forth? Howerd <howerdo@yahoo.co.uk> - 2017-03-21 12:48 -0700
  Re: MD4 in Forth? minforth@arcor.de - 2017-03-21 07:09 -0700
    Re: MD4 in Forth? Howerd <howerdo@yahoo.co.uk> - 2017-03-21 12:46 -0700
    Re: MD4 in Forth? Howerd <howerdo@yahoo.co.uk> - 2017-03-21 12:47 -0700
      Re: MD4 in Forth? Paul Rubin <no.email@nospam.invalid> - 2017-03-21 20:13 -0700
  Re: MD4 in Forth? Howerd <howerdo@yahoo.co.uk> - 2017-05-10 13:21 -0700
    Re: MD4 in Forth? Alex <alex@rivadpm.com> - 2017-05-10 23:27 +0100
    Re: MD4 in Forth? pahihu <pahihu@gmail.com> - 2017-05-11 05:10 -0700
      Re: MD4 in Forth? Howerd <howerdo@yahoo.co.uk> - 2017-05-11 22:07 -0700
        Re: MD4 in Forth? pahihu <pahihu@gmail.com> - 2017-05-12 04:58 -0700
          Re: MD4 in Forth? Howerd <howerdo@yahoo.co.uk> - 2017-05-12 08:17 -0700
            Re: Endian-swapping word ( was MD4 in Forth? ) Howerd <howerdo@yahoo.co.uk> - 2017-05-12 08:36 -0700
              Re: Endian-swapping word ( was MD4 in Forth? ) Raimond Dragomir <raimond.dragomir@gmail.com> - 2017-05-12 23:09 -0700
                Re: Endian-swapping word ( was MD4 in Forth? ) Howerd <howerdo@yahoo.co.uk> - 2017-05-13 07:04 -0700
                Re: Endian-swapping word ( was MD4 in Forth? ) Raimond Dragomir <raimond.dragomir@gmail.com> - 2017-05-13 10:05 -0700
              Re: Endian-swapping word ( was MD4 in Forth? ) David Schultz <abuse@127.0.0.1> - 2017-05-13 09:44 -0500

csiph-web