Before: [2, 1, 1, 0]56200
After: [2, 0, 1, 0]
Before: [3, 0, 3, 3]
d6264
After: [3, 1, 3, 3]
Before: [2, 2, 1, 2]
76301
After: [2, 2, 0, 2]
Before: [1, 1, 2, 1]
b6364
After: [1, 1, 0, 1]
Before: [3, 0, 3, 3]
a6301
After: [3, 0, 1, 3]
Before: [0, 2, 2, 2]
66361
After: [0, 2, 0, 2]
Before: [3, 2, 2, 0]
96201
After: [3, 3, 2, 0]
Before: [1, 1, 3, 3]
d6102
After: [2, 1, 3, 3]
Before: [2, 1, 2, 2]
56100
After: [0, 1, 2, 2]
Before: [1, 3, 2, 1]
26164
After: [2, 3, 2, 1]
Before: [2, 3, 1, 1]
26362
After: [2, 3, 4, 1]
Before: [1, 3, 2, 0]
06163
After: [3, 3, 2, 0]
Before: [1, 3, 2, 3]
36200
After: [1, 3, 2, 3]
Before: [2, 1, 3, 1]
26163
After: [5, 1, 3, 1]
Before: [0, 1, 3, 3]
d6404
After: [0, 1, 3, 4]
Before: [1, 4, 2, 3]
06462
After: [1, 4, 2, 7]
Before: [3, 1, 1, 1]
f6161
After: [9, 1, 1, 1]
Before: [3, 2, 3, 3]
e6302
After: [3, 2, 6, 3]
Before: [1, 2, 3, 2]
76332
After: [1, 2, 2, 2]
Before: [1, 1, 2, 3]
36405
After: [1, 1, 2, 7]
Before: [2, 1, 2, 3]
56101
After: [1, 1, 2, 3]
Before: [0, 1, 2, 3]
36365
After: [0, 1, 3, 3]
Before: [2, 1, 2, 2]
e6201
After: [2, 1, 2, 2]
Before: [2, 3, 3, 2]
e6404
After: [2, 3, 3, 8]
Before: [2, 1, 0, 2]
56200
After: [2, 0, 0, 2]
Before: [0, 1, 3, 1]
f6263
After: [0, 3, 3, 1]
Before: [6, 0, 6, 1]
b6163
After: [6, 0, 6, 1]
Before: [2, 2, 3, 2]
a6302
After: [2, 2, 2, 2]
Before: [0, 2, 2, 0]
96403
After: [0, 2, 2, 3]
Before: [2, 5, 2, 1]
66162
After: [5, 5, 2, 1]
Before: [3, 2, 0, 3]
e6102
After: [6, 2, 0, 3]
Before: [2, 3, 6, 0]
06361
After: [2, 3, 6, 0]
Before: [3, 1, 3, 1]
96204
After: [3, 5, 3, 1]
Before: [1, 1, 1, 2]
f6261
After: [1, 1, 1, 2]
Before: [2, 3, 0, 2]
36404
After: [2, 3, 0, 6]
Before: [3, 1, 2, 1]
a610d
After: [1, 1, 2, 1]
Before: [1, 1, 2, 2]
b6362
After: [1, 1, 0, 2]
Before: [0, 2, 1, 1]
26162
After: [2, 2, 1, 1]
Before: [3, 2, 1, 1]
76168
After: [2, 2, 1, 1]
Before: [2, 2, 3, 4]
66264
After: [2, 4, 3, 4]
— Assignment 2: Assembunny Opcodes –Looking further, you find another page in the manual. According to the manual, the device has
four registers (labeled a through d) that can be manipulated by instructions containing one of 16
opcodes.
Every instruction consists of four values: a 4 bit opcode, one 8 bit output in ASCII (called x), and
an 8 bit input which is either ASCII or hex (called y). The opcode specifies the behavior of the
instruction and how the inputs are interpreted. The output, x, is always treated as a register.
In the opcode descriptions below, if something says “value y”, it means to take the number given
as y literally. (This is also called an “immediate” value.) If something says “register y”, it means
to use the number given as y to read from (or write to) the register with that letter. So, if the
opcode add adds register x and value y, storing the result in register x, and the instruction add a
7 is encountered, it would add 7 to the value contained by register a and store the sum in register
a, never modifying registers b, c, or d in the process.
Many opcodes are similar except for how they interpret their arguments. The opcodes fall into
seven general categories:
add x,y:
Add Register stores into register x the result of adding register x and register y.
Add Immediate stores into register x the result of adding register x and value y.
imul x,y:
Signed Multiply Register stores into register x the result of multiplying register x and
register y.
Signed Multiply Immediate stores into register x the result of multiplying register x and
value y.
and x,y:
Bitwise AND Register stores into register x the result of the bitwise AND of register x
and register y.
Bitwise AND Immediate stores into register x the result of the bitwise AND of register x
and value y.
or x,y:
Bitwise OR Register stores into register x the result of the bitwise OR of register x and
register y.
Bitwise OR Immediate stores into register x the result of the bitwise OR of register x and
value y.
mov x,y:
Move Register copies the contents of register y into register x.
Move Immediate stores value y into register x.
Unfortunately, while the manual gives the name of each opcode, it doesn’t seem to indicate the
number. However, you find some print outs of example operations so you can see the contents of
the registers before and after instructions are executed to try to work them out. Each opcode has
a number from 0 through 15, but the manual doesn’t say which is which. For example, suppose
you capture the following sample:
a b c d
Before: [3, 2, 1, 1]
96202
After: [3, 4, 1, 1]
This sample shows the effect of the instruction 96301 on the registers. Before the instruction is
executed, register a has value 3, register b has value 2, and registers c and d have value 1. After
the instruction is executed, register b’s value becomes 4.
The instruction itself, 96301, means that opcode 9 was executed with x=b, and y=2. Opcode 9
could be any of the 16 opcodes listed above, but only two of them behave in a way that would
cause the result shown in the sample:
Opcode 9 could be Add Immediate: register b (which has a value of 2) plus value 2
produces 4, which matches the value stored in the output register, register b.
Opcode 9 could be Signed Multiply Immediate: register b (which has a value of 2) times
value 2 produces 4, which matches the value stored in the output register, register b.
None of the other opcodes produce the result captured in the sample. Because of this, in the
sample above 9 is either Add Immediate or Signed Multiple Immediate.
You collect many of these samples from around the warehouse.
Using the samples you collected (a2_input.txt), work out the number of each opcode and submit
the opcodes (in Octal) with their commands. Bonus points if you correctly identify the inc and
dec commands from last week.
Problem adapted from Advent of Code 2018 Day 16.
Please match the instruction with its opcode (in octal).
Group of answer choices
Add Register [ Choose ]
Add Immediate [ Choose ]
Signed Multiply Register[ Choose = ]
Signed Multiply Immediate[ Choose ]
Bitwise AND Register [ Choose ]
Bitwise AND Immediate [ Choose ]
Bitwise OR Register[ Choose ]
Bitwise OR Immediate [ Choose ]
Move Register[ Choose ]
Move Immediate[ Choose ]
Please match the instruction with its opcode (in octal).
Group of answer choices
Add Register [ Choose ]
Add Immediate [ Choose ]
Signed Multiply Register[ Choose = ]
Signed Multiply Immediate[ Choose ]
Bitwise AND Register [ Choose ]
Bitwise AND Immediate [ Choose ]
Bitwise OR Register[ Choose ]
Bitwise OR Immediate [ Choose ]
Move Register[ Choose ]
Move Immediate[ Choose ]
#
What is the code for inc?
#
What is the code for dec?
Please match the instruction with its opcode (in octal).
Add Register
Add Immediate
Signed Multiply Register
Signed Multiply Immediate
Bitwise AND Register
Bitwise AND Immediate
Bitwise OR Register
Bitwise OR Immediate
Move Register
Move Immediate
[Choose ]
[Choose ]
[Choose ]
[Choose ]
[Choose ]
[Choose ]
[Choose ]
[Choose ]
[Choose ]
[Choose ]
<
>
<
<
>