Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

--- Assignment 1: Assembunny Interpreter Bored with sitting around the house all day, you decide to investigate an abandoned warehouse near where you live.




imageimageimage

--- 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 +

Step by Step Solution

3.43 Rating (150 Votes )

There are 3 Steps involved in it

Step: 1

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fraud examination

Authors: Steve Albrecht, Chad Albrecht, Conan Albrecht, Mark zimbelma

4th edition

538470844, 978-0538470841

More Books

Students also viewed these Programming questions