▓ ANOMALY DETECTED — UNAUTHORIZED MEMORY STATE — NEW ENTRY UNLOCKED ▓
ZERO PAGE Microprocessor Systems Lab
CLK: 00000000
[ SANDBOX MODE — GRADING DISABLED — DIRECT MEMORY ACCESS ENABLED ]
Mission Brief
FIELD BALLISTICS UNIT — PROTO A
Artillery unit reports systematic deviation in impact coordinates. Field sensors return raw range data, but atmospheric wind drift introduces consistent offset. Command requires real-time correction computation for target acquisition. You have been assigned to program the correction module.
Objectives
Read RAW RANGE from $00
Read WIND DRIFT from $01
Store ($00 - $01) & $FF into $02
Do not modify $00 or $01
Terminate with BRK
Complete within 500 cycles
Technical Reference
LDA #$nn — Load literal value $nn into A
LDA $nn — Load value at memory address $nn into A
STA $nn — Store A into memory address $nn
ADC #$nn — Add $nn to A (use CLC first for clean addition)
ADC $nn — Add value at $nn to A
SBC #$nn — Subtract $nn from A (use SEC first)
SBC $nn — Subtract value at $nn from A
CMP $nn — Compare A to $nn. Sets flags; does not change A
AND #$nn / AND $nn — Bitwise AND. Keeps only bits set in both A and operand
ORA #$nn / ORA $nn — Bitwise OR. Sets bits in A where either operand has a 1
EOR #$nn / EOR $nn — Bitwise XOR. Flips bits in A where operand has a 1
BCS label — Branch if C=1 (carry set — A ≥ compared value)
BCC label — Branch if C=0 (carry clear — A < compared value)
BEQ label — Branch if Z=1 (result was zero / values were equal)
BNE label — Branch if Z=0 (result was non-zero / values differ)
BMI label — Branch if N=1 (result was negative, bit 7 set)
BPL label — Branch if N=0 (result was positive or zero)
SEC — Set carry flag (required before SBC)
CLC — Clear carry flag (required before ADC chains)
BRK — Halt execution. Program must reach BRK to pass tests

LDX #$nn / LDX $nn — Load X register with value
LDY #$nn / LDY $nn — Load Y register with value
STX $nn — Store X into memory.  STY $nn — Store Y into memory
INX / DEX — Increment / Decrement X. Sets N, Z
INY / DEY — Increment / Decrement Y. Sets N, Z
TAX — Copy A→X.  TAY — Copy A→Y.  TXA — Copy X→A.  TYA — Copy Y→A
CPX #$nn / CPX $nn — Compare X to value. Sets N, Z, C (C=1 if X≥val)
CPY #$nn / CPY $nn — Compare Y to value. Sets N, Z, C (C=1 if Y≥val)

LDA $nn,X — Load from address ($nn + X), wraps in zero page
STA $nn,X — Store A to address ($nn + X), zero page wrap
LDA $nn,Y / STA $nn,Y — Same but indexed by Y
LDA ($nn),Y — Indirect indexed. Reads 16-bit pointer from $nn/$nn+1, adds Y for final address
STA ($nn),Y — Store via indirect pointer + Y
LDA ($nn,X) — Indexed indirect. Adds X to $nn; reads 16-bit pointer from that address
STA ($nn,X) — Store via pointer selected by $nn+X

INC $nn — Increment memory byte. $FF wraps to $00. Sets N, Z
DEC $nn — Decrement memory byte. $00 wraps to $FF. Sets N, Z
BIT $nn — Test bits. Sets N=bit7, V=bit6, Z=(A AND mem)=0. Does not change A

ASL — Shift A left 1 bit (×2). Old bit 7 → C.  ASL $nn — shift memory
LSR — Shift A right 1 bit (÷2). Old bit 0 → C.  LSR $nn — shift memory
ROL — Rotate A left through carry. bit 7→C, old C→bit 0.  ROL $nn — rotate memory
ROR — Rotate A right through carry. bit 0→C, old C→bit 7.  ROR $nn — rotate memory

JSR label — Jump to subroutine at label. Pushes return address on stack
RTS — Return from subroutine. Pops return address from stack
JMP label — Unconditional jump. Does not push stack
PHA — Push A onto stack.  PLA — Pull A from stack (LIFO)
NOP — No operation. 1 cycle, no effect

FLAGS: N=negative (bit7)  Z=zero  C=carry/borrow  V=overflow
SBC requires SEC first. ADC chains need CLC first to prevent carry leaking between additions.
Stack lives at $0100–$01FF. SP starts at $FF. Labels are case-sensitive.
All values wrap to 8-bit ($00–$FF). Memory $00–$FF is zero page only.
Assembly Editor — Mission 1
1
FRAMEBUFFER $80–$FF
16×8 px  |  addr = $80 + (y×16) + x
00 = off  |  nonzero = on
Machine State
A
00
X
00
Y
00
SP
FF
N
0
V
0
-
-
B
0
D
0
I
0
Z
0
C
0
PC0000
CYCLES0
Memory $00–$0F
Full Memory $00–$FF CLICK TO EDIT
LCD Display
RAW RANGE $00 00
WIND DRIFT $01 00
CORRECTED $02 00
RANDOM $FE 00
KEY INPUT $FF 00
READY — SYSTEM INITIALIZED