BTW, is the .NET representation of your objects a reference or a value type?
I believe it would be classed a reference type according to the msdn library http://msdn.microsoft.com/en-us/libr...(v=VS.80).aspx


Reference Types


Reference types include the following:

String


All arrays, even if their elements are value types


Class types, such as Form


Delegates
and not to mention it is declared:

public ref class BI{

and immutability is the way to go as far as Im concerned for a project like this, however, because of the immutability on a class such as this, whenever you do +-/*%, Pow, ModPow or anything that changes it, an entire new object is created, the effect on a class such as this (since it is a value type however microsoft defines it) is that during execution there are a whole bunch of instances being created and destroyed. Because of that fact I have often considered taking the immutability out of it, at the same time Im afraid to because of how much time it took me to get this version of it thread safe.


Ive been playing with the idea of the structures a little bit, but I am having a problem with the named pointers. Right now I have for the structures:

Code:
			BI				struct

				_sign			qword		0
				_num			qword		0

			BI				ends

			BD				struct

				_decimalplace	qword	0
				_num			BI		{}

			BD				ends

			BF			struct

				_numerator		BI		{}
				_denominator	BI	{}

			BF			ends
now I wrote a little routine just to investigate into it a little bit, and just looking at the BI structures (one thing at a time). if I use the lea instruction on the _sign and _num variables, I get and address for the _num variable that is 8 greater then the _sign, which is exactly what I expected. I can use instances of these structures that are passed in, locally declared variables, and variables declared in the dseg section just fine, by that I mean I can use instructions such as _val._sign and _val._num[rdi] and such just fine with expected results. However, when trying to create one of these dynamically I am having trouble assigning the _sign and _num the adresses from the requested memory. The CreateBI routine looks like this:

Code:

	BuildBI PROC _arraysize:qword

		LOCAL _as:qword
		LOCAL _signpos:qword
		LOCAL _numpos:qword
		LOCAL _ret:BI

		lea		r10, _ret._sign
		lea		r11, _ret._num
		push	rdi
		mov		_as, rcx
		lea		r12, _ret
		mov		rcx, _as
		add		rcx, 16
		sub		rsp, 28h
		call	GetMem64
		add		rsp, 28h
		cmp		rax, 0
		je		MallocError
		mov		qword ptr[rax],0
		mov		_ret._sign, rax
		add		rax, 8
		mov		_ret._num, rax
		mov		rcx, _as
		mov		qword ptr[rax], rcx
		mov		rdi, 1
		lea		r8, _ret._num

ClearArray:

		mov		_ret._num[rdi], 0
		inc		rdi
		cmp		rdi, qword ptr[rax]
		jna		ClearArray
		mov		rax, _signpos
		pop		rdi
		RET

MallocError:

	BuildBI ENDP
I know that using a local variable in this way is completely ignorant, but I wanted to see how it could be done with a known instance of it. When I try to assign the address to the _sign and _num variables in the above instance, it is storing the values at the address they are currently pointing to instead of changing the address. Ive also tried using a statement such as mov [rcx].BI._sign, rax (with rcx containing the return value for the requested memory). BTW the above statement works for accessing variables in the structure if I do something like lea rcx, _val1, but again, its not changing the address it points to, it just changes the value at the address it is pointing to. How do I change where it points to?

I also tried things like mov _ret, rax (where rax points to the first memory address returned from the request for memory) and mov BI ptr _ret, rax. In both cases I get an error saying instruction operands must be the same size.

I can use what is returned from the CreateBI routine with instructions such as mov rcx, qword ptr[rax] (this would move the sign into rcx), and mov rdx, qword ptr[rax+8] or mov rdx, qword ptr[rax+rdi*8+8] (the first moves the 0 element of the array into rdx, and the second moving the rdi element into rdx), and I can use instructions such as mov rdx, [rax].BI._num[rdi]. even though I havent tried yet, I am sure that the BD will not be a problem either, but I am sure the BF structure is going to be a problem if I cant point the _denominator (since it is the second BI listed) to the correct memory location. even if I were to do something like make one request for memory large enough for both arrays, I dont know at design time how big array 1 will be, I am sure with the way it is set up now, that if I were to look into the BF with the lea instruction it would show me _numerator._sign as the base address, _numerator._num would equal _numerator._sign+8, and _denominator._sign would equal _numerator._sign + 16, and finally _denominator._num would equal _numerator._sign + 24. Any ideas on how to change the address they are pointing to? Is there a way to declare the array in the structure as an array without specifying how many elements it has?