--- Assignment 1: Assembunny Interpreter Bored with sitting around the house all day, you decide...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
--- Assignment 1: Assembunny Interpreter · Bored with sitting around the house all day, you decide to investigate an abandoned warehouse near where you live. In a drawer you find some code and rules for instructions that look familiar, but also strange. The back of the papers have doodles of bunnies on it, so you decide to call it assembunny language. Assembunny code is very similar to assembly code with a few exceptions: 1. Instead of ax, bx, cx, dx, or eax, ebx, ecx, edx, that could have any value to start and hold a specific number of bytes, the assembunny code operates on four registers called a, b, c, and d that start at 0 and can hold any integer. 2. Instead of jumping to a named location (which we will learn about soon) you jump a specific number of instructions. 3. Compare is simplified from what is in the book, we'll add more later after we learn about cmp. For this assignment implement the following instructions: • mov x, y inc x • dec x • cmp x, y jnz x copies y (either an integer or the value of a register) into register x. increases the value of register x by one. decreases the value of register x by one. A simplified version of cmp that checks if the numbers are equal and sets the "zero flag" if they are. jumps to an instruction x away (positive means forward; negative means backward), but only if the zero flag is not set. The jnz instruction moves relative to itself: an offset of -1 would continue at the previous instruction, while an offset of 2 would skip over the next instruction. For example: mov a, 41 inc a inc a dec a cmp a, 0 jnz 2 dec a The above code would set register a to 41, increase its value by 2, decrease its value by 1, and then skip the last dec a (because a is not zero, so the jnz 2 skips it), leaving register a at 42. When you move past the last instruction, the program halts. Read the given input file ("al_input.txt") using relative addressing. After executing the assembunny code in your input file, output the value of register a. Problem adapted from Advent of Code 2016 Day 12. - Assignment 3: Assembunny Part 2. After you figure out the opcodes, you find a program that tests them in another stack of papers. However, before you can test out the new code, you need to add the new operations to your code from Part 1. Specifically you need to add add, imul, and, and or to your Assembunny Interpreter from Assignment 1. Read the input file ("a3_input.txt") using relative addressing After executing the assembunny code in your input file, output the value of register a. Problem adapted from Advent of Code 2018 Day 16. a3_input.txt imul a, 97 add d, 2 mov b,0 add a, 2 imul a, 3 add c, a mov a, 1 mov b, 2 add c, d mov d, c mov c, 3 imul a,1 imul a, 1 add d, a mov c, d mov d, 0 mov a, 2 mov b, 1 add c, d mov a, c add c, 3 add d, 1 add a, c mov b,0 add d, 2 mov c, 2 or c, 3 add a,c mov d, a mov c, 2 mov b,1 mov a, 1 mov a, a imul a,1 imul a,1 add d, a mov b, d mov a, 1 mov d, 0 mov d, a add b,d mov d, 2 add a, 2 add b,d mov a, 1 mov d, 1 add d, d add b,d mov d,b mov b,3 mov c, 3 add d, b Download → Info × Close Page < 1 > of 13 - ZOOM + --- Assignment 1: Assembunny Interpreter · Bored with sitting around the house all day, you decide to investigate an abandoned warehouse near where you live. In a drawer you find some code and rules for instructions that look familiar, but also strange. The back of the papers have doodles of bunnies on it, so you decide to call it assembunny language. Assembunny code is very similar to assembly code with a few exceptions: 1. Instead of ax, bx, cx, dx, or eax, ebx, ecx, edx, that could have any value to start and hold a specific number of bytes, the assembunny code operates on four registers called a, b, c, and d that start at 0 and can hold any integer. 2. Instead of jumping to a named location (which we will learn about soon) you jump a specific number of instructions. 3. Compare is simplified from what is in the book, we'll add more later after we learn about cmp. For this assignment implement the following instructions: • mov x, y inc x • dec x • cmp x, y jnz x copies y (either an integer or the value of a register) into register x. increases the value of register x by one. decreases the value of register x by one. A simplified version of cmp that checks if the numbers are equal and sets the "zero flag" if they are. jumps to an instruction x away (positive means forward; negative means backward), but only if the zero flag is not set. The jnz instruction moves relative to itself: an offset of -1 would continue at the previous instruction, while an offset of 2 would skip over the next instruction. For example: mov a, 41 inc a inc a dec a cmp a, 0 jnz 2 dec a The above code would set register a to 41, increase its value by 2, decrease its value by 1, and then skip the last dec a (because a is not zero, so the jnz 2 skips it), leaving register a at 42. When you move past the last instruction, the program halts. Read the given input file ("al_input.txt") using relative addressing. After executing the assembunny code in your input file, output the value of register a. Problem adapted from Advent of Code 2016 Day 12. - Assignment 3: Assembunny Part 2. After you figure out the opcodes, you find a program that tests them in another stack of papers. However, before you can test out the new code, you need to add the new operations to your code from Part 1. Specifically you need to add add, imul, and, and or to your Assembunny Interpreter from Assignment 1. Read the input file ("a3_input.txt") using relative addressing After executing the assembunny code in your input file, output the value of register a. Problem adapted from Advent of Code 2018 Day 16. a3_input.txt imul a, 97 add d, 2 mov b,0 add a, 2 imul a, 3 add c, a mov a, 1 mov b, 2 add c, d mov d, c mov c, 3 imul a,1 imul a, 1 add d, a mov c, d mov d, 0 mov a, 2 mov b, 1 add c, d mov a, c add c, 3 add d, 1 add a, c mov b,0 add d, 2 mov c, 2 or c, 3 add a,c mov d, a mov c, 2 mov b,1 mov a, 1 mov a, a imul a,1 imul a,1 add d, a mov b, d mov a, 1 mov d, 0 mov d, a add b,d mov d, 2 add a, 2 add b,d mov a, 1 mov d, 1 add d, d add b,d mov d,b mov b,3 mov c, 3 add d, b Download → Info × Close Page < 1 > of 13 - ZOOM +
Expert Answer:
Answer rating: 100% (QA)
Required C code which uses vector to read file include iostream include fstream include string include vector void assembunnyconst stdstring filename stdvector int registers4 0 stdvector std string in... View the full answer
Related Book For
Fraud examination
ISBN: 978-0538470841
4th edition
Authors: Steve Albrecht, Chad Albrecht, Conan Albrecht, Mark zimbelma
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
A buyer's guide is an example of OA) a Life Insurance Illustration Questionnaire O B) a Replacement Questionnaire OC) a required disclosure document OD) a Variable Life Insurance Illustration...
-
What is the difference between a vertical alliance and a horizontal alliance?
-
Each of the following investments is independent of the others. 1. A bond that will mature in four years was bought one month ago when the price dropped. As soon as the value increases, which is...
-
A beetle that has an inertia of \(4.0 \times 10^{-6} \mathrm{~kg}\) sits on the floor. It jumps by using its muscles to push against the floor and raise its center of mass. (a) If its center of mass...
-
1. What was the most important reason for Lehman Brothers failure? 2. What is leverage and why is it so important? 3. Prepare the journal entries for a Repo 105 transaction sequence for $1 million in...
-
You are an investment banker in a major US firm and receive info from time to time from corporate clients re: takeover activities. A friend who is a securities trader in another brokerage firm has...
-
The lifetime (in months) of a battery is modeled by a random variable X that has pdf f ( x ) = K x 1 ( x > 0 ) where K = ln ( 1 / ) for an unknown parameter ( 0 , 1 ) . (Here 1 ( x > 0 )...
-
Do the memo analyzes with two strengths, two weaknesses, and make two recommendations to improve the company. The financial statements provided in this practice set can also be downloaded from...
-
Waiting times to receive food after placing an order at the local Subway sandwich shop follow an exponential distribution with a mean of 72 seconds. Calculate the probability a customer waits: a....
-
A driver who previously presented with hypertension and BP at 186/112 returns for re-evaluation with BP at 136/84. What approach will you take with this driver? Explain briefly.
-
Hello Class, Lacy Wilson wants to buy a investment propeity of real estate in 7 years' valued at $ 500,000 she already has $137,000 saved up, and it is invested and earning 20% per year. Will she...
-
Jar tests were performed on untreated river water. An optimum dose of 12.5 mg/L of alum was determined. Determine the amount of natural alkalinity (mg/L as. CaCO3) consumed. If 50 x 10 gal/day of raw...
-
A cell phone manufacturer inspects the video display on each color phone to verify that the screen can display all colors with the brilliance their customers have come to expect. Each phone is turned...
-
Fill in the blanks: We observed 28 successes in 70 independent trials. Compute a 95% confidence interval for the population p. E = lower limit = upper limit =
-
To balance the chemical equation SiH3 + O2 SiO2 + HO, you could introduce coefficients a, b, c, d and write aSiH3 + bO2 cSiO + dHO then write linear equations for each element. The equation for Si...
-
To help you understand the material discussed in the chapter, do the following: 1. Give at least three characteristics of a grand jury. 2. Without looking at the list in the chapter, list at least...
-
When fraud is committed, criminal prosecution usually proceeds first. (True/False)
-
Why is it important to disclose only a portion of the circumstantial evidence you have collected?
-
Explain the concept of a control variable and the assumption necessary for a control variable to be effective.
-
From output of your computer software, locate (a) the sum of squared errors, (b) the \(F\)-value for the overall significance of a regression model, (c) the estimated covariance matrix for the least...
-
Obtain restricted least squares estimates that include nonsample information in the estimation procedure.
Study smarter with the SolutionInn App