Implement MIMA Function EQL adr - Wondering

  • MHB
  • Thread starter mathmari
  • Start date
  • Tags
    Function
In summary, the MIMA commands are: LCD const, LDV adr, STV adr, ADD adr, STV adr, JMN x, LDC -1, JMP z, x: LCD 0, z: NOT, m: LCD 0, n: STV adr. The code to initialize the memory cell y with 1 and to add the value of y by itself and the result put at y using the MIMA commands is correct. The subtraction of 3 times 2^3 can be done using the following code: while1: LDC 0, while2: LDC 0, end1: LDC 1, end2: LDC 1.
  • #1
mathmari
Gold Member
MHB
5,049
7
Hey! :eek:

We have that MIMA (Neumann MInimal MAchine) has the following commands:
Code:
LCD const   :  Load constant 
LDV adr      :  Load value from address 
LDIV adr     :  Load value indirect from address 
STV adr      :  Set value at address 
STIV adr     :  Set value indirect at address

View attachment 6290

Code:
NOT            :   Inverse of the constant-bits   
RAR            :   Rotate accumulator right

View attachment 6291

Code:
ADD adr      :   Addition 
AND adr      :   bitwise AND 
OR  adr       :   bitwise OR 
XOR adr      :   bitwise exclusive OR

View attachment 6292

Code:
JMP  adr      :   Jump 
JMN adr       :   Jump if negative
I want to write a MIMA program that takes the value $2^{23}-24=8.388.584$ to the memory $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.

How do exactly do we make the representation? (Wondering)

The other part is the following, or not?
Code:
LDC  const 
STIV  y
Then I want to implement the Mima-command EQL adr (equal?) with the other Mima-commands.

We have that for that command it holds the following: $$\text{Accu} \leftarrow \left\{\begin{matrix}
-1 , &\text{ Accu }=M(adr)\\
0 , &\text{otherwise}
\end{matrix}\right.$$

I have done the following:
My idea is to compute -M(adr) and then to add it to Accu, and then to check if it i <0.
And then to compute the inverse of the result and check if it is <0.
Is it correct? (Wondering)

Code:
LCD const 
LDV adr 
NOT 
STV adr 
ADD adr 
STV adr 
JMN x 
LDC -1 
JMP z 
x: LCD 0 
z: NOT 
   JMN m 
   LDC -1 
   JMP n 
   m: LCD 0 
   n: STV adr

Is the implementation correct? Could I improve something? (Wondering)
 

Attachments

  • mima.PNG
    mima.PNG
    7.4 KB · Views: 83
  • not.PNG
    not.PNG
    4.4 KB · Views: 89
  • arith.PNG
    arith.PNG
    6.6 KB · Views: 85
Last edited by a moderator:
Technology news on Phys.org
  • #2
We have also the following information about the bits:
Address: 20 Bit and Values: 24 Bit
 
  • #3
About 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 an other memory cell, say $a$, for that? (Wondering)

Let $x$ be the memory cell where the representation of $23$ in two's complement is, and let $z$ be the memory cell where the representation of $3$ in two's complement is.

I wrote the following code (about the part of $2^3$ I computed it in the way we compute $2^{23}$ and I subtracted it three times from $y$):

Code:
            LCD 1 
            STV y 
while1:     LDC 0 
            NOT 
            ADD x 
            STV x 
            JMN end1 
            LDV y 
            ADD y 
            STV y 
           JMP while1 
end1:       LDC 1 
            STV a 
while2:     LDC 0 
            NOT 
            ADD z 
            STV  z
            JMN end2 
            LDV a 
            ADD a 
            STV a 
            JMP while2 
end2:       LDV a 
            NOT 
            ADD y 
            LDV a 
            NOT 
            ADD y 
            LDV a 
            NOT 
            ADD y 
            HALT
Is this correct? (Wondering)
 

FAQ: Implement MIMA Function EQL adr - Wondering

What is the purpose of implementing MIMA function EQL adr?

The purpose of implementing MIMA function EQL adr is to compare two memory addresses and determine if they are equal. This is a useful function in programming as it allows for conditional statements and logical operations.

How does MIMA function EQL adr work?

MIMA function EQL adr works by taking in two memory addresses as inputs and comparing them. If the addresses are equal, the function will return a value of 1, otherwise it will return a value of 0.

What is the syntax for using MIMA function EQL adr?

The syntax for using MIMA function EQL adr is as follows: EQL adr, address1, address2. This will compare the values stored at the two addresses and return either a 1 or 0 depending on the result.

Can MIMA function EQL adr be used for other data types besides memory addresses?

No, MIMA function EQL adr is specifically designed to compare memory addresses and cannot be used for other data types. For other data types, there are specific functions or operators that can be used for comparison.

What happens if I use MIMA function EQL adr with invalid or non-existent memory addresses?

If you use MIMA function EQL adr with invalid or non-existent memory addresses, the function will return an error or an undefined value. It is important to ensure that the addresses used are valid and exist in the memory before using this function.

Similar threads

Replies
2
Views
1K
Replies
1
Views
1K
Replies
6
Views
1K
Replies
1
Views
2K
Replies
6
Views
6K
Replies
3
Views
936
Replies
5
Views
2K
Replies
13
Views
2K
Back
Top