Ad
  • Custom User Avatar
    • jnz x y - jumps to an instruction y steps away (positive means forward, negative means backward, y can be a register or a constant), but only if x (a constant or a register) is not zero

    jnz 5 10 -> 5 here is a constant, which is not zero, which means your next step should be jumping forward 10 steps, which ends the program.

    Not a kata issue.

  • Default User Avatar

    I believe this test case if wrong: { "mov d 100", "dec d", "mov b d", "jnz b -2", "inc d", "mov a d", "jnz 5 10", "mov c a" }
    When the code reaches the "jnz 5 10" no registers has the value 5.\

    Breakdown:
    mov d 100 -> d is 100
    dec 9 -> d is 99
    mov b d -> botb b and d are 99
    jnz b -2 -> we decrease the value of d then copy d's value to b until d is 0, so d and b is 0 when we reach the "inc d" instruction
    inc d -> d is 1 b is 0
    mov a d -> d and a are 1, b is 0
    jnz 5 10 -> no register has 5 as value