rifter1818 Posted March 8, 2004 Posted March 8, 2004 Is there any way to Access Memory one bit at a time? Have say 9699690 bits of memory 1's and 0's and read and write to each memory bit? Quote
Joe Mamma Posted March 8, 2004 Posted March 8, 2004 (edited) Is there any way to Access Memory one bit at a time? Have say 9699690 bits of memory 1's and 0's and read and write to each memory bit?1. Point to your memory and cast as a Int64[] 2. Grab each Int64 containing the bit you want to change. 3. Perform Bitwise arithmetic on the Int64 to modify the nth bit to set bit n : myInt64 |= Math.Pow(2,n-1); to clear bit n : myInt64 = ~(( ~myInt64 ) ^ ( Math.Pow(2,n-1) )); There might be a more efficient method for the bit clear, but that should work. Boolean algebra was always confusing to me. joe mamma Edited March 8, 2004 by Joe Mamma Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
HJB417 Posted March 9, 2004 Posted March 9, 2004 1. Point to your memory and cast as a Int64[] 2. Grab each Int64 containing the bit you want to change. 3. Perform Bitwise arithmetic on the Int64 to modify the nth bit to set bit n : myInt64 |= Math.Pow(2,n-1); to clear bit n : myInt64 = ~(( ~myInt64 ) ^ ( Math.Pow(2,n-1) )); There might be a more efficient method for the bit clear, but that should work. Boolean algebra was always confusing to me. joe mamma You can always have the BitArray Class do the math for you :D Quote
*Experts* Nerseus Posted March 9, 2004 *Experts* Posted March 9, 2004 Is there any way to Access Memory one bit at a time? Have say 9699690 bits of memory 1's and 0's and read and write to each memory bit? Are you sure you mean one bit at a time and not one byte? If you did mean bit, try the suggestions above. If you meant byte, just create a byte array. Now if you want a specific chunk of memory that's a bit different. If you want a chunk in another process (not from your app, but someone else's) that's yet another story. -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Joe Mamma Posted March 9, 2004 Posted March 9, 2004 clarification of my original Is there any way to Access Memory one bit at a time? Have say 9699690 bits of memory 1's and 0's and read and write to each memory bit?I just want to clarify that you need to work with the values in the array, as I am afraid, you might not get what you are looking for. 1. Point to your memory and cast as a Int64[], myInt64s 2. Advance to the Int64 containing the bit you want to change. 3. Perform Bitwise arithmetic to modify the nth bit of myInt64s to set bit n : myInt64 |= Math.Pow(2,n-1); to clear bit n : myInt64 = ~((~myInt64)^(Math.Pow(2,n-1))); There might be a more efficient method for the bit clear, but that should work. Boolean algebra was always confusing to me. joe mamma Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.