Question: Your task Your code should 1 . Load the values in memory at addresses 0 x 0 1 and 0 x 0 3 into registers
Your task
Your code should
Load the values in memory at addresses x and x into registers
Note: since we have not discussed ways to get other data into our memory yet, we will directly modify your code so that the second x and fourth x bytes are the input values. This means your first x and third x bytes instructions should be very specific operations.
Compute the modulo of those values iewhats at x mod whats at x
Store the product at address xD
Halt once it is done
For example, if mod.binary begins then when it is finished it should have in address xD; in decimal, that is mod which is If mod.binary begins F A then when it is finished it should have in address xD; in decimal, that is mod which is
Note: We should be able to change the second and fourth bytes of your program to do other modulo calculations too.
You may assume that neither value will be negative, but either may be zero. If either operand is your code should set the value at xD to x
Hints, tips, and suggestions
How to compute modulo
Modulo, a mod n or a n is defined as the remainder when dividing a by n As in our examples above with mod where the quotient is and the remainder is Therefore, mod
Hint: For the division operation, think along the lines of how many times can fit into You may wish to consider multiples of
You definitely want to make sure you can write working code for this in some language you know well before trying to convert that code into binary.
How to write binary
We suggest following these steps, carefully, saving the result of each in a file so you can go back and fix them if they were wrong:
Write pseudocode that does the desired task
Convert any for loops to while loops with explicit counters
Change any if or while guards to the form something
a b becomes ab
a b becomes a b becomes ab
a b becomes ba becomes ba
a b becomes ba becomes ba
a b becomes ab becomes ab becomes ab
a b becomes ab becomes ab becomes ab
Add more variables to split multioperation lines into a series of singleoperation lines
Add more operations to convert ones not in the instruction set into ones in the instruction set
Change each loop into a pair of instructions, opening with spot pc and closing with if goto spot
Count the number of variables needed
If it is skip to step
else continue with next step
Pick a memory address for each variable. Make these big enough your code is unlikely to get that big; for example, you might pick x though x number of variables
Convert each statement that uses variables into
register load variables memory
original statement
store variables memory register
translate each instruction into numeric icode a b triples, possibly followed by a Mpc immediate value
turn icode a b into hex
Write all the hex into mod.binary
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
