A higher resolution is required to access the IDE
- 1
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
A simple 8-bit CPU emulator must be debugged. The CPU has 4 registers (R0, R1, R2, R3) initialized to 0.Instructions are encoded as hexadecimal bytes:
Where X and Y are register indices (0-3), and V is an immediate byte value.
All arithmetic wraps at 256 (8-bit unsigned). Overflow wraps to 0, underflow wraps to 255.
The first instruction is not guaranteed to be
The smallest valid program is just
Execute the program and output the final register values.
Input
Line 1: A string of space-separated hexadecimal bytes program
Output
4 lines: The decimal value of each register R0, R1, R2, R3, one value per line
Constraints
Program length ≤ 100 bytes
For the opcodes02 , 03 and 04 , X ≠ Y
Program always ends with HLT (FF ) as an opcode. Byte value FF may also appear as an immediate value V.
For the opcodes
Program always ends with HLT (
Example
Input
01 00 0A 01 01 05 02 00 01 03 00 01 FF
Output
10 5 0 0
A higher resolution is required to access the IDE