> Are you shifting just one bit at a time?
>
> If so, could you use something like
>
> ADD RO,RO ; shifts left one bit, zero in bit zero
> ADDC #0, R0 ; put the carry bit into bit zero
>
> Mark Borgerson
Yes, one bit at a time!
My father told me the same thing yesterday,
but, comming from the Z80 world, we both concluded that
ADC will destroy the final carry flag.
But not in ARM, since avery inctruction MAY have S suffix!
So, this should work:
adds r2, r2, r2 ; shift & update carry
adc r2, r2, #0 ; complete the shift, do not change carry
Thank you
Reply by Mark Borgerson●November 12, 20102010-11-12
In article <dYd*si2nt@news.chiark.greenend.org.uk>, paulg@at-cantab-
dot.net says...
> aleksa <aleksazr@gmail.com> wrote:
> > x86 ROL does this:
>
> > bit 0 to bit 1... bit 30 to bit 31
> > bit 31 to both bit 0 and carry flag.
>
> You can't do exactly the same in one instruction you can do either
>
> "ROR provides the value of the contents of a register rotated by a
> value. The bits that are rotated off the right end are inserted into
> the vacated bit positions on the left."
>
Hmmm, except for the carry, could you you use ROR #31, R0 to get
the equivalent of a 1-bit ROL?
Could you generalize that for ROL with more than one bit as something
like ROR #(32-shift), RO?
I can see this one is going to cost me a sheet of paper---either that
or I give up and just go have a drink while someone else thinks about
it! ;-)
> "RRX provides the value of the contents of a register shifted right one
> bit. The old carry flag is shifted into bit[31]. If the S suffix is
> present, the old bit[0] is placed in the carry flag."
>
Mark Borgerson
Reply by Mark Borgerson●November 12, 20102010-11-12
In article <ibk0fi$k6s$2@news.eternal-september.org>, aleksazr@gmail.com
says...
> x86 ROL does this:
>
> bit 0 to bit 1... bit 30 to bit 31
> bit 31 to both bit 0 and carry flag.
>
> Since I'm new to arm asm, is there a quick way of doing this?
> Or should I just change the algo to use ARM's ROR?
>
>
>
Are you shifting just one bit at a time?
If so, could you use something like
ADD RO,RO ; shifts left one bit, zero in bit zero
ADDC #0, R0 ; put the carry bit into bit zero
If you're shifing multiple bits, I'm not sure what significance
the carry bit would have after you're done.
Being unfamiliar with the arm assembly language, I don't know if
the above is either valid or proper syntax.
Mark Borgerson
Reply by aleksa●November 12, 20102010-11-12
"Paul Gotch" <paulg@at-cantab-dot.net> wrote in message news:dYd*si2nt@news.chiark.greenend.org.uk...
> aleksa <aleksazr@gmail.com> wrote:
>> x86 ROL does this:
>
>> bit 0 to bit 1... bit 30 to bit 31
>> bit 31 to both bit 0 and carry flag.
>
> You can't do exactly the same in one instruction you can do either
>
> "ROR provides the value of the contents of a register rotated by a
> value. The bits that are rotated off the right end are inserted into
> the vacated bit positions on the left."
>
> "RRX provides the value of the contents of a register shifted right one
> bit. The old carry flag is shifted into bit[31]. If the S suffix is
> present, the old bit[0] is placed in the carry flag."
>
> -p
> --
> Paul Gotch
> --------------------------------------------------------------------
ROR doesn't update the carry flag? (with bit 0)
Reply by Paul Gotch●November 12, 20102010-11-12
aleksa <aleksazr@gmail.com> wrote:
> x86 ROL does this:
> bit 0 to bit 1... bit 30 to bit 31
> bit 31 to both bit 0 and carry flag.
You can't do exactly the same in one instruction you can do either
"ROR provides the value of the contents of a register rotated by a
value. The bits that are rotated off the right end are inserted into
the vacated bit positions on the left."
"RRX provides the value of the contents of a register shifted right one
bit. The old carry flag is shifted into bit[31]. If the S suffix is
present, the old bit[0] is placed in the carry flag."
-p
--
Paul Gotch
--------------------------------------------------------------------
Reply by aleksa●November 12, 20102010-11-12
x86 ROL does this:
bit 0 to bit 1... bit 30 to bit 31
bit 31 to both bit 0 and carry flag.
Since I'm new to arm asm, is there a quick way of doing this?
Or should I just change the algo to use ARM's ROR?