473,803 Members | 3,943 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

bitwise rotation

Greetings,

I am simulating an assembly language bit rotation in C# and it works
wonderfully

---------
....
public uint Value;
....
public uint RotateRight(byt e count) {
Value = ((Value >> count) | (Value << (32-count)));
return Value;
}
---------

as long is the value is 32-bit or 64-bit (because of a limitation of the
shift operator). I need it to work on an 8-bit or 16-bit value, as well. I
presume I'd have to have knowledge of the intended size of the value and do
the shift and move the bit and the 0 or 7, or 0 or 15 bit position and clear
the extra bits if there are any. That seems like a lot of work.

Is there a way to simulate an 8 or 16-bit rotate with a 32-bit or 64-bit
value?
Thanks,
Shawn
Nov 15 '05 #1
33 2562
How about:

public uint RotateRight16(u int Value, byte Count)
{
return ((Value >> Count) | (Value << (16-Count)))&0xffff ;
}
public uint RotateRight8(ui nt Value, byte Count)
{
return ((Value >> Count) | (Value << (8-Count)))&0xff;
}

public uint RotateLeft16(ui nt Value, byte Count)
{
return ((Value << Count) | (Value >> (16-Count)))&0xffff ;
}
public uint RotateLeft8(uin t Value, byte Count)
{
return ((Value << Count) | (Value >> (8-Count)))&0xff;
}

--
Robert Jeppesen
robert.jeppesen %at%durius-dot-se
"Shawn B." <le****@html.co m> wrote in message news:O9******** *******@TK2MSFT NGP11.phx.gbl.. .
Greetings,

I am simulating an assembly language bit rotation in C# and it works
wonderfully

---------
...
public uint Value;
...
public uint RotateRight(byt e count) {
Value = ((Value >> count) | (Value << (32-count)));
return Value;
}
---------

as long is the value is 32-bit or 64-bit (because of a limitation of the
shift operator). I need it to work on an 8-bit or 16-bit value, as well. I
presume I'd have to have knowledge of the intended size of the value and do
the shift and move the bit and the 0 or 7, or 0 or 15 bit position and clear
the extra bits if there are any. That seems like a lot of work.

Is there a way to simulate an 8 or 16-bit rotate with a 32-bit or 64-bit
value?
Thanks,
Shawn

Nov 15 '05 #2
Oops, forgot to make sure that value is within limits:

public static uint RotateRight16(u int Value, byte Count)
{
return (((Value&0xffff ) >> Count) | (Value << (16-Count)))&0xffff ;
}
public static uint RotateLeft16(ui nt Value, byte Count)
{
return ((Value << Count) | ((Value&0xffff) >> (16-Count)))&0xffff ;
}

etc for 8-bit.

--
Robert Jeppesen
robert.jeppesen %at%durius-dot-se
"Robert Jeppesen" <robert.jeppese n(#)durius.se> wrote in message news:eE******** ******@TK2MSFTN GP11.phx.gbl...
How about:

public uint RotateRight16(u int Value, byte Count)
{
return ((Value >> Count) | (Value << (16-Count)))&0xffff ;
}
public uint RotateRight8(ui nt Value, byte Count)
{
return ((Value >> Count) | (Value << (8-Count)))&0xff;
}

public uint RotateLeft16(ui nt Value, byte Count)
{
return ((Value << Count) | (Value >> (16-Count)))&0xffff ;
}
public uint RotateLeft8(uin t Value, byte Count)
{
return ((Value << Count) | (Value >> (8-Count)))&0xff;
}

--
Robert Jeppesen
robert.jeppesen %at%durius-dot-se
"Shawn B." <le****@html.co m> wrote in message news:O9******** *******@TK2MSFT NGP11.phx.gbl.. .
Greetings,

I am simulating an assembly language bit rotation in C# and it works
wonderfully

---------
...
public uint Value;
...
public uint RotateRight(byt e count) {
Value = ((Value >> count) | (Value << (32-count)));
return Value;
}
---------

as long is the value is 32-bit or 64-bit (because of a limitation of the
shift operator). I need it to work on an 8-bit or 16-bit value, as well. I
presume I'd have to have knowledge of the intended size of the value and do
the shift and move the bit and the 0 or 7, or 0 or 15 bit position and clear
the extra bits if there are any. That seems like a lot of work.

Is there a way to simulate an 8 or 16-bit rotate with a 32-bit or 64-bit
value?
Thanks,
Shawn


Nov 15 '05 #3
Hard to believe it was so simple, I tried that... except where you're
16-count is, I left it at 64 bits with the 8-bit mask, that explains why it
was wrong.

Thanks very much,
Shawn
"Robert Jeppesen" <robert.jeppese n(#)durius.se> wrote in message
news:eE******** ******@TK2MSFTN GP11.phx.gbl...
How about:

public uint RotateRight16(u int Value, byte Count)
{
return ((Value >> Count) | (Value << (16-Count)))&0xffff ;
}
public uint RotateRight8(ui nt Value, byte Count)
{
return ((Value >> Count) | (Value << (8-Count)))&0xff;
}

public uint RotateLeft16(ui nt Value, byte Count)
{
return ((Value << Count) | (Value >> (16-Count)))&0xffff ;
}
public uint RotateLeft8(uin t Value, byte Count)
{
return ((Value << Count) | (Value >> (8-Count)))&0xff;
}

--
Robert Jeppesen
robert.jeppesen %at%durius-dot-se
"Shawn B." <le****@html.co m> wrote in message

news:O9******** *******@TK2MSFT NGP11.phx.gbl.. .
Greetings,

I am simulating an assembly language bit rotation in C# and it works
wonderfully

---------
...
public uint Value;
...
public uint RotateRight(byt e count) {
Value = ((Value >> count) | (Value << (32-count)));
return Value;
}
---------

as long is the value is 32-bit or 64-bit (because of a limitation of the
shift operator). I need it to work on an 8-bit or 16-bit value, as well. I presume I'd have to have knowledge of the intended size of the value and do the shift and move the bit and the 0 or 7, or 0 or 15 bit position and clear the extra bits if there are any. That seems like a lot of work.

Is there a way to simulate an 8 or 16-bit rotate with a 32-bit or 64-bit
value?
Thanks,
Shawn


Nov 15 '05 #4
So, you're writing an emulator for which processor??

--
Bob Powell [MVP]
C#, System.Drawing

September's edition of Well Formed is now available.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

"Shawn B." <le****@html.co m> wrote in message
news:O9******** *****@TK2MSFTNG P11.phx.gbl...
Greetings,

I am simulating an assembly language bit rotation in C# and it works
wonderfully

---------
...
public uint Value;
...
public uint RotateRight(byt e count) {
Value = ((Value >> count) | (Value << (32-count)));
return Value;
}
---------

as long is the value is 32-bit or 64-bit (because of a limitation of the
shift operator). I need it to work on an 8-bit or 16-bit value, as well. I presume I'd have to have knowledge of the intended size of the value and do the shift and move the bit and the 0 or 7, or 0 or 15 bit position and clear the extra bits if there are any. That seems like a lot of work.

Is there a way to simulate an 8 or 16-bit rotate with a 32-bit or 64-bit
value?
Thanks,
Shawn

Nov 15 '05 #5
Don't miss a thing, d'ya? =))

I'm writing a processor Simulator for the 8-bit 6502, 8-bit 65c02, and the
16-bit 65816. In particular, I'm doing this so I can debug (I have the
ability to modify the assembly language while the debugger is running
(similar to VB6 and VC++ Edit-and-Continue). I can only see raw
instructions. I'm not designing it to be a particular piece of hardware
(such as the Apple, Atari, Commadore, etc.). I can supply it plugins so my
plugins can treat an area of memory as a dedicated "something" such as text
display or graphics display, etc. For now, I'm concerned not even with the
text display. My end result, is actually more akin to being able to debug
my NES games I've been into writing lately. Also I want to be ready with my
own debugger for Andre LaMothe's upcoming XGameStation console (don't know
whether he'll have a debugger or not) but I want a debugger that allows me
to change the code while it's being debugged and my simulator allows for it
(as long as the source code file is available -- else if it was loading as a
..bin file then it won't be editable during a debug session).

So it's really more than a simulator. It's an integrated (non-seperable)
assembly, linker, dissassembler, debugger, simulator, etc. kind of a beast.
I chose C# because it's not the kind of thing I'd want to do in VB.NET (I'm
primarly a VB.NET programmer) but didn't feel like doing it in Managed C++
but also wanted it to target the .NET framework (as much as is reasonable
and I'll find out what that really means when its mature enough to start
using reliably).

I can do a decent job emulating 1-5MHz in C# on my PIII 1000MHz CPU with
GeForce II 64MB and 512MB Ram. I don't know how well it'll do emulating the
16-bit processor as I haven't deciphered the specs for the CPU yet (the
8-bit CPU is very easy compared to the 16-bit version of the processor). I
ultimately will make this Interfacable so I can write a Z80 core, as well.

These bit manipulations are the utmost inner-loop so I have to make them
tight. Looking at the JIT'd code for these methods seems to be decent but I
have to make too many function calls (read, jumps) for my tastes but doesn't
seem to be hurting me at the moment). Since I can't inline in .NET, I'll
have to live with it. Also, being an 8-bit and 16-bit CPU, it can't
generate the best code for the rotates and shifts because I have to emulate
8-bit and 16-bit shifts and rotates. I'm also trying to work out a better
way for simulating memory manipulation. Now I'm creating a string of (64kb
in length) but manipulating each byte by substrings has got to be expensive.
I'm looking into whether a byte array would be better.
Thanks for the help,
if interested, I'll post my binary class here for all to see.

I've completed the Rotates, Shift, converting numerics into binary (string
of 1's and 0's). I know now have to read the binary back to a numeric, and
allow a way to get/set/toggle individual bits.
Thanks,
Shawn
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
So, you're writing an emulator for which processor??

--
Bob Powell [MVP]
C#, System.Drawing

September's edition of Well Formed is now available.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

"Shawn B." <le****@html.co m> wrote in message
news:O9******** *****@TK2MSFTNG P11.phx.gbl...
Greetings,

I am simulating an assembly language bit rotation in C# and it works
wonderfully

---------
...
public uint Value;
...
public uint RotateRight(byt e count) {
Value = ((Value >> count) | (Value << (32-count)));
return Value;
}
---------

as long is the value is 32-bit or 64-bit (because of a limitation of the
shift operator). I need it to work on an 8-bit or 16-bit value, as
well. I
presume I'd have to have knowledge of the intended size of the value and

do
the shift and move the bit and the 0 or 7, or 0 or 15 bit position and

clear
the extra bits if there are any. That seems like a lot of work.

Is there a way to simulate an 8 or 16-bit rotate with a 32-bit or 64-bit
value?
Thanks,
Shawn


Nov 15 '05 #6
Do post it here!
I'd be interested to see, as I'm sure many others would.
You'll probably get a ton of optimization hints from it. :)
--
Robert Jeppesen
robert.jeppesen %at%durius-dot-se
"Shawn B." <le****@html.co m> wrote in message news:OW******** ******@tk2msftn gp13.phx.gbl...
Don't miss a thing, d'ya? =))

I'm writing a processor Simulator for the 8-bit 6502, 8-bit 65c02, and the
16-bit 65816. In particular, I'm doing this so I can debug (I have the
ability to modify the assembly language while the debugger is running
(similar to VB6 and VC++ Edit-and-Continue). I can only see raw
instructions. I'm not designing it to be a particular piece of hardware
(such as the Apple, Atari, Commadore, etc.). I can supply it plugins so my
plugins can treat an area of memory as a dedicated "something" such as text
display or graphics display, etc. For now, I'm concerned not even with the
text display. My end result, is actually more akin to being able to debug
my NES games I've been into writing lately. Also I want to be ready with my
own debugger for Andre LaMothe's upcoming XGameStation console (don't know
whether he'll have a debugger or not) but I want a debugger that allows me
to change the code while it's being debugged and my simulator allows for it
(as long as the source code file is available -- else if it was loading as a
.bin file then it won't be editable during a debug session).

So it's really more than a simulator. It's an integrated (non-seperable)
assembly, linker, dissassembler, debugger, simulator, etc. kind of a beast.
I chose C# because it's not the kind of thing I'd want to do in VB.NET (I'm
primarly a VB.NET programmer) but didn't feel like doing it in Managed C++
but also wanted it to target the .NET framework (as much as is reasonable
and I'll find out what that really means when its mature enough to start
using reliably).

I can do a decent job emulating 1-5MHz in C# on my PIII 1000MHz CPU with
GeForce II 64MB and 512MB Ram. I don't know how well it'll do emulating the
16-bit processor as I haven't deciphered the specs for the CPU yet (the
8-bit CPU is very easy compared to the 16-bit version of the processor). I
ultimately will make this Interfacable so I can write a Z80 core, as well.

These bit manipulations are the utmost inner-loop so I have to make them
tight. Looking at the JIT'd code for these methods seems to be decent but I
have to make too many function calls (read, jumps) for my tastes but doesn't
seem to be hurting me at the moment). Since I can't inline in .NET, I'll
have to live with it. Also, being an 8-bit and 16-bit CPU, it can't
generate the best code for the rotates and shifts because I have to emulate
8-bit and 16-bit shifts and rotates. I'm also trying to work out a better
way for simulating memory manipulation. Now I'm creating a string of (64kb
in length) but manipulating each byte by substrings has got to be expensive.
I'm looking into whether a byte array would be better.
Thanks for the help,
if interested, I'll post my binary class here for all to see.

I've completed the Rotates, Shift, converting numerics into binary (string
of 1's and 0's). I know now have to read the binary back to a numeric, and
allow a way to get/set/toggle individual bits.
Thanks,
Shawn
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
So, you're writing an emulator for which processor??

--
Bob Powell [MVP]
C#, System.Drawing

September's edition of Well Formed is now available.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

"Shawn B." <le****@html.co m> wrote in message
news:O9******** *****@TK2MSFTNG P11.phx.gbl...
Greetings,

I am simulating an assembly language bit rotation in C# and it works
wonderfully

---------
...
public uint Value;
...
public uint RotateRight(byt e count) {
Value = ((Value >> count) | (Value << (32-count)));
return Value;
}
---------

as long is the value is 32-bit or 64-bit (because of a limitation of the
shift operator). I need it to work on an 8-bit or 16-bit value, as

well.
I
presume I'd have to have knowledge of the intended size of the value and

do
the shift and move the bit and the 0 or 7, or 0 or 15 bit position and

clear
the extra bits if there are any. That seems like a lot of work.

Is there a way to simulate an 8 or 16-bit rotate with a 32-bit or 64-bit
value?
Thanks,
Shawn



Nov 15 '05 #7
Robert,

Youre suggestions have transformed my operations into 1-liners from 5
liners... you'll be the first to be notified (on these groups, of course).

I've opted to create a series of classes, Binary8, Binary16, Binary32,
Binary64 (all are unsigned).

I need to know, when you say "int x = 10;" is that a compiler trick or is
there a way to create my own type that can do that, for example, "Binary8 x
= 0xFF;"???
Thanks,
Shawn

"Robert Jeppesen" <robert.jeppese n(#)durius.se> wrote in message
news:Oi******** ******@TK2MSFTN GP09.phx.gbl...
Do post it here!
I'd be interested to see, as I'm sure many others would.
You'll probably get a ton of optimization hints from it. :)
--
Robert Jeppesen
robert.jeppesen %at%durius-dot-se
"Shawn B." <le****@html.co m> wrote in message

news:OW******** ******@tk2msftn gp13.phx.gbl...
Don't miss a thing, d'ya? =))

I'm writing a processor Simulator for the 8-bit 6502, 8-bit 65c02, and the 16-bit 65816. In particular, I'm doing this so I can debug (I have the
ability to modify the assembly language while the debugger is running
(similar to VB6 and VC++ Edit-and-Continue). I can only see raw
instructions. I'm not designing it to be a particular piece of hardware
(such as the Apple, Atari, Commadore, etc.). I can supply it plugins so my plugins can treat an area of memory as a dedicated "something" such as text display or graphics display, etc. For now, I'm concerned not even with the text display. My end result, is actually more akin to being able to debug my NES games I've been into writing lately. Also I want to be ready with my own debugger for Andre LaMothe's upcoming XGameStation console (don't know whether he'll have a debugger or not) but I want a debugger that allows me to change the code while it's being debugged and my simulator allows for it (as long as the source code file is available -- else if it was loading as a .bin file then it won't be editable during a debug session).

So it's really more than a simulator. It's an integrated (non-seperable) assembly, linker, dissassembler, debugger, simulator, etc. kind of a beast. I chose C# because it's not the kind of thing I'd want to do in VB.NET (I'm primarly a VB.NET programmer) but didn't feel like doing it in Managed C++ but also wanted it to target the .NET framework (as much as is reasonable and I'll find out what that really means when its mature enough to start
using reliably).

I can do a decent job emulating 1-5MHz in C# on my PIII 1000MHz CPU with
GeForce II 64MB and 512MB Ram. I don't know how well it'll do emulating the 16-bit processor as I haven't deciphered the specs for the CPU yet (the
8-bit CPU is very easy compared to the 16-bit version of the processor). I ultimately will make this Interfacable so I can write a Z80 core, as well.
These bit manipulations are the utmost inner-loop so I have to make them
tight. Looking at the JIT'd code for these methods seems to be decent but I have to make too many function calls (read, jumps) for my tastes but doesn't seem to be hurting me at the moment). Since I can't inline in .NET, I'll have to live with it. Also, being an 8-bit and 16-bit CPU, it can't
generate the best code for the rotates and shifts because I have to emulate 8-bit and 16-bit shifts and rotates. I'm also trying to work out a better way for simulating memory manipulation. Now I'm creating a string of (64kb in length) but manipulating each byte by substrings has got to be expensive. I'm looking into whether a byte array would be better.
Thanks for the help,
if interested, I'll post my binary class here for all to see.

I've completed the Rotates, Shift, converting numerics into binary (string of 1's and 0's). I know now have to read the binary back to a numeric, and allow a way to get/set/toggle individual bits.
Thanks,
Shawn
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
So, you're writing an emulator for which processor??

--
Bob Powell [MVP]
C#, System.Drawing

September's edition of Well Formed is now available.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

"Shawn B." <le****@html.co m> wrote in message
news:O9******** *****@TK2MSFTNG P11.phx.gbl...
> Greetings,
>
> I am simulating an assembly language bit rotation in C# and it works
> wonderfully
>
> ---------
> ...
> public uint Value;
> ...
> public uint RotateRight(byt e count) {
> Value = ((Value >> count) | (Value << (32-count)));
> return Value;
> }
> ---------
>
> as long is the value is 32-bit or 64-bit (because of a limitation of the > shift operator). I need it to work on an 8-bit or 16-bit value, as

well.
I
> presume I'd have to have knowledge of the intended size of the value and do
> the shift and move the bit and the 0 or 7, or 0 or 15 bit position and clear
> the extra bits if there are any. That seems like a lot of work.
>
> Is there a way to simulate an 8 or 16-bit rotate with a 32-bit or 64-bit > value?
>
>
> Thanks,
> Shawn
>
>



Nov 15 '05 #8
Shawn B. <le****@html.co m> wrote:
I need to know, when you say "int x = 10;" is that a compiler trick or is
there a way to create my own type that can do that, for example, "Binary8 x
= 0xFF;"???


It's not really a compiler trick, it's just that the type of 10 is int,
so the compiler can just assign that value to the variable.

I believe if you give the Binary8 class an implicit conversion from
int, you could get away with it.

I'm not sure whether or not you could get away with giving an implicit
conversion from byte, letting the compiler figure out that it can
convert a constant expression of type int to byte, and then from byte
to Binary8 - if that works though, it would remove the need for range
checking in your conversion.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #9
In addition to Jon's response,
No, you can't overload the = operator.
Found a nice summary of what can be overloaded:
http://www.csharphelp.com/archives/archive135.html

--
Robert Jeppesen
robert.jeppesen %at%durius-dot-se
"Shawn B." <le****@html.co m> wrote in message news:ez******** ******@tk2msftn gp13.phx.gbl...
Robert,

Youre suggestions have transformed my operations into 1-liners from 5
liners... you'll be the first to be notified (on these groups, of course).

I've opted to create a series of classes, Binary8, Binary16, Binary32,
Binary64 (all are unsigned).

I need to know, when you say "int x = 10;" is that a compiler trick or is
there a way to create my own type that can do that, for example, "Binary8 x
= 0xFF;"???
Thanks,
Shawn

"Robert Jeppesen" <robert.jeppese n(#)durius.se> wrote in message
news:Oi******** ******@TK2MSFTN GP09.phx.gbl...
Do post it here!
I'd be interested to see, as I'm sure many others would.
You'll probably get a ton of optimization hints from it. :)
--
Robert Jeppesen
robert.jeppesen %at%durius-dot-se
"Shawn B." <le****@html.co m> wrote in message

news:OW******** ******@tk2msftn gp13.phx.gbl...
Don't miss a thing, d'ya? =))

I'm writing a processor Simulator for the 8-bit 6502, 8-bit 65c02, and the 16-bit 65816. In particular, I'm doing this so I can debug (I have the
ability to modify the assembly language while the debugger is running
(similar to VB6 and VC++ Edit-and-Continue). I can only see raw
instructions. I'm not designing it to be a particular piece of hardware
(such as the Apple, Atari, Commadore, etc.). I can supply it plugins so my plugins can treat an area of memory as a dedicated "something" such as text display or graphics display, etc. For now, I'm concerned not even with the text display. My end result, is actually more akin to being able to debug my NES games I've been into writing lately. Also I want to be ready with my own debugger for Andre LaMothe's upcoming XGameStation console (don't know whether he'll have a debugger or not) but I want a debugger that allows me to change the code while it's being debugged and my simulator allows for it (as long as the source code file is available -- else if it was loading as a .bin file then it won't be editable during a debug session).

So it's really more than a simulator. It's an integrated (non-seperable) assembly, linker, dissassembler, debugger, simulator, etc. kind of a beast. I chose C# because it's not the kind of thing I'd want to do in VB.NET (I'm primarly a VB.NET programmer) but didn't feel like doing it in Managed C++ but also wanted it to target the .NET framework (as much as is reasonable and I'll find out what that really means when its mature enough to start
using reliably).

I can do a decent job emulating 1-5MHz in C# on my PIII 1000MHz CPU with
GeForce II 64MB and 512MB Ram. I don't know how well it'll do emulating the 16-bit processor as I haven't deciphered the specs for the CPU yet (the
8-bit CPU is very easy compared to the 16-bit version of the processor). I ultimately will make this Interfacable so I can write a Z80 core, as well.
These bit manipulations are the utmost inner-loop so I have to make them
tight. Looking at the JIT'd code for these methods seems to be decent but I have to make too many function calls (read, jumps) for my tastes but doesn't seem to be hurting me at the moment). Since I can't inline in .NET, I'll have to live with it. Also, being an 8-bit and 16-bit CPU, it can't
generate the best code for the rotates and shifts because I have to emulate 8-bit and 16-bit shifts and rotates. I'm also trying to work out a better way for simulating memory manipulation. Now I'm creating a string of (64kb in length) but manipulating each byte by substrings has got to be expensive. I'm looking into whether a byte array would be better.
Thanks for the help,
if interested, I'll post my binary class here for all to see.

I've completed the Rotates, Shift, converting numerics into binary (string of 1's and 0's). I know now have to read the binary back to a numeric, and allow a way to get/set/toggle individual bits.
Thanks,
Shawn
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
> So, you're writing an emulator for which processor??
>
> --
> Bob Powell [MVP]
> C#, System.Drawing
>
> September's edition of Well Formed is now available.
> http://www.bobpowell.net/currentissue.htm
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/gdiplus_faq.htm
>
>
>
> "Shawn B." <le****@html.co m> wrote in message
> news:O9******** *****@TK2MSFTNG P11.phx.gbl...
> > Greetings,
> >
> > I am simulating an assembly language bit rotation in C# and it works
> > wonderfully
> >
> > ---------
> > ...
> > public uint Value;
> > ...
> > public uint RotateRight(byt e count) {
> > Value = ((Value >> count) | (Value << (32-count)));
> > return Value;
> > }
> > ---------
> >
> > as long is the value is 32-bit or 64-bit (because of a limitation of the > > shift operator). I need it to work on an 8-bit or 16-bit value, as
well.
> I
> > presume I'd have to have knowledge of the intended size of the value and > do
> > the shift and move the bit and the 0 or 7, or 0 or 15 bit position and > clear
> > the extra bits if there are any. That seems like a lot of work.
> >
> > Is there a way to simulate an 8 or 16-bit rotate with a 32-bit or 64-bit > > value?
> >
> >
> > Thanks,
> > Shawn
> >
> >
>
>



Nov 15 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
7203
by: Ramtin Kazemi | last post by:
Hi How can i perform bitwise rotation in C#?
0
10548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10295
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.