z-procesor
Mr. Little Z has designed his first CPU, and he needs your help to test it.
The processor (CPU) has K registers, and they are all initialized to 0 - each of the registers stores a number 0. Also, each of the registers works in "mod 10000" meaning that if you load a number N into register A, then register A will actually store N mod 10000.
The processor supports the following set of instructions:
1. INC R N - The content of the register R will be increased by N, where N is an integer (0 <= N <= 5000). Hence the new content of the register R will equal to (Rold + N) MOD 10000
2. ADD R1 R2 R3 - The values from registers R1 and R2 are added and the result is stored in R3
3. MUL R1 R2 R3 - The values from registers R1 and R2 are multiplied and the result is stored in R3
4. OUT R - The content of the register R is printed to the standard output
Your task is to write a program that will simulate the processor that Mr. Little Z has designed.
2
AX
BX
6
INC AX 10
INC BX 10
MUL AX BX AX
OUT AX
ADD AX BX BX
OUT BXOutput:
100
110The input will always contain at least 1 OUT instruction
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.