[Community Puzzle] MiniCPU Instruction Decoder - Puzzle discussion

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @YALOKGAR,validated by @User123,@Cakeisalie5 and @field3.
If you have any issues, feel free to ping them.

For some reason I fail the Complex Calculation validator, which makes no sense. Should I be error handling for instructions outside of the given instructions? Also, should I be worried that V might be greater than 0xFF? Otherwise, my program should work just fine.

You can send me (in private) your script/code, I’ll look what’s happening.

I think the problem is not clear at all.

For everyone struggling with Complex Calculation validator, please, make sure that your overflow logic accounts for the possibility of multiple overflows (e.g. 260 overflows to 4, but so does 516, 772 or 1028; same goes for underflows)

1 Like

Hey @MartinienGABA! Thanks for trying the puzzle out. Which part of the problem is unclear to you?

I feel the same, instructions are not clear

Huh, I loved this puzzle, and instructions were pretty clear to me, but I already had experience in this field. What exactly is not clear to you?

I understand the part where 01 means MOV, 02 means ADD and so on. But I don’t quit get the example provided, it says 01 00 0A 01 01 05 02 00 01 03 00 01 FF this is the input right, so 01 means MOV followed by 00, what’s 00? is it a value that is supposed to be moved? and what’s 0A?

So yeah, I had to stop and think for a while to understand that too. So you have a list of numbers separated by spaces. Some numbers mean instructions - 01-06 and FF, some mean registers - 00-03, and some just values - 00-FF. So you start with an instruction, check how many arguments it has, process it, then go to next instruction. Does it make sense? I could explain what exactly is happening in the example, if you want.

Yeah, It would be really helpful if you could explain what is happening in the example because I am still confused.

Gladly. Let’s break it down.
01 00 0A 01 01 05 02 00 01 03 00 01 FF:

  • first we have 01, which is MOV and it takes 2 arguments: X V, so it’s the 1st instruction: 01 00 0A,
  • then goes another MOV, it’s our 2nd instruction: 01 01 05,
  • then we have 02, which is ADD and it also takes 2 arguments: X Y, it’s our 3rd instruction: 02 00 01,
  • then we have 03, which is SUB and it still takes 2 arguments: X Y, so 03 00 01 is our 4th instruction,
  • and finally FF, which is HLT, it’s the end of the program, this instruction takes no arguments.

So example program which has 13 numbers has 5 instructions.
Now let’s break down first MOV instruction.
01 00 0A:

  • 00 is number of the register, so register 0,
  • and 0A is the value.

In pseudocode this is as simple as setting the variable: register0 = 0A. We work with registers, which means we already have 4 variables.

1 Like

Thanks a lot for this amazing explanation, my confusion is clear now :slight_smile:

1 Like