# Representation of the number in two's complement

We have that MIMA (Neumann MInimal MAchine) has the following commands:

I want to write a MIMA program that takes the value $2^{23}-24=8.388.584$ to the memory cell $y$. We have to take attention at the number of the bits, that we need for the representation of the number in two's complement.

I have done the following:

We have that $2^{n+1}=2\cdot 2^n=2^n+2^n$.

So, $$2^1=2^0+2^0=1+1 \\ 2^2=2^1+2^1=(1+1)+(1+1) \\ 2^3=2^2+2^2=[(1+1)+(1+1)]+[(1+1)+(1+1)] \\ \text{etc}$$

And we have that $24=2^3\cdot 3=2^3+2^3+2^3$.

We initialize the memory cell $y$ with $1$ and we repeat $23$ times to add the value of $y$ by itself and the result we put it at $y$.

Then we have to subtract three times $2^3$.

How do we do this? Do we have to compute again the $2^3$'s, then compute the inverse and add it to the value that is at $y$ ?

But where do we do these operations? To calculate $2^3$ as above, we have to save the results at each step, or not? But where? Do we consider for that an other memory cell?

• This is more about programming MIMA than actual two's complement... – Evil Dec 21 '16 at 3:16
• Community votes, please: offtopic? – Raphael Dec 21 '16 at 6:14
• looks ok to me as exercise in Turing completeness, also would like to know where this architecture is studied in the literature & whether von neumann (cofather of CS) had anything to do with it – vzn Dec 21 '16 at 18:34
• on 2nd look this seems to be a trivial exercise in assembly language concepts. answer: LDC x, STV y. x=$2^{23}-24$. however, different cpus have different n-bit limits on constants, that is not specified here. eg 8 bit processors have a byte limit. if the constant is greater than the operand size then it can be saved over multiple load/stores. & then endian order comes into play. etc – vzn Dec 22 '16 at 1:26
• So, we don't have to write the number first in two's complement? @vzn – Mary Star Dec 22 '16 at 9:26