Level 25: Negative Check

Task

Learn the JN (Jump if Negative) conditional jump. Run the test program and verify the jump works.

JN (Jump if Negative) — conditional jump that triggers when bit 7 of the result = 1 (negative number in two's complement).

Solution

Hardware implementation: 1. Splitter extracts bit 7 from the ALU output (Negative flag). 2. AND gate combines: Decoder.JumpCond AND Bit7. 3. OR gate combines: JumpUncond OR (JumpCond AND Bit7) → PC.Load. 4. When PC.Load=1, the program counter loads the jump address from the operand.

Test program: - LDA 10 → Acc = 10 - STA 10 → RAM[10] = 10 - LDA 5 → Acc = 5 - SUB 10 → Acc = 5 − RAM[10] = 5 − 10 = 251 (bit 7 = 1, negative) - JN negative → jumps (bit 7 = 1) - LDA 99 → Acc = 99 - HLT

If JN works, Acc = 99. If not, Acc stays at 251.

Click "Run", then "Checkpoint".

Assembler help →