gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Moving along with mc


From: Gaius Mulley
Subject: Re: Moving along with mc
Date: Thu, 29 Jul 2021 13:55:55 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Benjamin Kowarsch <trijezdci@gmail.com> writes:

> On Mon, 26 Jul 2021 at 07:04, Gaius Mulley <mulley.gaius@gmail.com>
> wrote:
>     
>     it should be possible to extend mc to translate SHIFT and ROTATE
>     of word sized quantities fairly easily - will look into this at
>     some point.
>
> Since the dialect to be translated here is PIM, not ISO, may I suggest
> that you implement this in a Wirthian and not in an ISO manner.
>
> Wirth has always implemented bit operations with specific discrete
> procedures, never one-size-fits-all procedures.
>
> By contrast, SHIFT and ROTATE are distinctly ISO and they are
> problematic, typical committee creations.
>
> The reason why these are bad designs is that there are logic and
> arithmetic variants.
>
> For left shift/rotate, logic and arithmetic variants are identical,
> but for right shift/rotate they are not.
>
> Consequently, in his various Modula-2 and Oberon compilers, Wirth has
> consistently implemented
>
> * SHL for left shift
> * SHR for logical right shift
> * ASHR for arithmetic right shift
>
> There is also the possibility one may need a shift through a carry bit
> as this allows the construction of cascading shifts on arbitrary sized
> data.
>
> SHLC for left shift through a carry bit
>
> https://github.com/m2sf/m2bsk/blob/master/src/lib/IntBitOps.def#L40
>
> This way, user code can shift arbitrarily sized data one chunk at a
> time, using the carry bit to fill the right most bit in the next
> chunk.
>
> A similar argument can be made for rotation. Besides, the procedures
> should be consistent, that is to say, if shifting is provided by
> separate procedures, then so should rotation if only for the sake of
> consistency of interface.

Hi Benjamin,

thanks for bringing this up - yes this makes sense and as you say is in
line with other M2 compiler implementations.  I'll alter mc to adopt
this approach,

regards,
Gaius



reply via email to

[Prev in Thread] Current Thread [Next in Thread]