- Maciek MaĆecki, 2020 -
"These computers did not come with operating systems. They didn't even come with file systems. What you got was an assembler."
Robert C. Martin, Clean Architecture: A Craftsman's Guide to Software Structure and Design
169 0 141 32 208 169 1 141 32 208 76 0 192
169 0
141 32 208
169 1
141 32 208
76 0 192
$A9 $00
$8D $20 $D0
$A9 $01
$8D $20 $D0
$4C $00 $C0
- human readable form of machine code
- translator (a program) from assembly into the machine code
LDA value
+----------------+-----------------------+---------+---------+----------+
| Addressing Mode| Assembly Language Form| OP CODE |No. Bytes|No. Cycles|
+----------------+-----------------------+---------+---------+----------+
| Immediate | LDA #$FF | $A9 | 2 | 2 |
| ZeroPage | LDA $FF | $A5 | 2 | 3 |
| ZeroPage,X | LDA $FF,X | $B5 | 2 | 4 |
| Absolute | LDA $FFFF | $AD | 3 | 4 |
| Absolute,X | LDA $FFFF,X | $BD | 3 | 4* |
| Absolute,Y | LDA $FFFF,Y | $B9 | 3 | 4* |
| (Indirect,X) | LDA ($FF,X) | $A1 | 2 | 6 |
| (Indirect),Y | LDA ($FF),Y | $B1 | 2 | 5* |
+----------------+-----------------------+---------+---------+----------+
*add extra 1 cycle if crossing 256b page boundary
ADC Add Memory to Accumulator with Carry LDA Load Accumulator with Memory
AND "AND" Memory with Accumulator LDX Load Index X with Memory
ASL Shift Left One Bit (Memory or Accumulator) LDY Load Index Y with Memory
LSR Shift Right One Bit (Memory or Accumulator)
BCC Branch on Carry Clear
BCS Branch on Carry Set NOP No Operation
BEQ Branch on Result Zero
BIT Test Bits in Memory with Accumulator ORA "OR" Memory with Accumulator
BMI Branch on Result Minus
BNE Branch on Result not Zero PHA Push Accumulator on Stack
BPL Branch on Result Plus PHP Push Processor Status on Stack
BRK Force Break PLA Pull Accumulator from Stack
BVC Branch on Overflow Clear PLP Pull Processor Status from Stack
BVS Branch on Overflow Set
ROL Rotate One Bit Left (Memory or Accumulator)
CLC Clear Carry Flag ROR Rotate One Bit Right (Memory or Accumulator)
CLD Clear Decimal Mode RTI Return from Interrupt
CLI Clear interrupt Disable Bit RTS Return from Subroutine
CLV Clear Overflow Flag
CMP Compare Memory and Accumulator SBC Subtract Memory from Accumulator with Borrow
CPX Compare Memory and Index X SEC Set Carry Flag
CPY Compare Memory and Index Y SED Set Decimal Mode
SEI Set Interrupt Disable Status
DEC Decrement Memory by One STA Store Accumulator in Memory
DEX Decrement Index X by One STX Store Index X in Memory
DEY Decrement Index Y by One STY Store Index Y in Memory
INC Increment Memory by One TAX Transfer Accumulator to Index X
INX Increment Index X by One TAY Transfer Accumulator to Index Y
INY Increment Index Y by One TSX Transfer Stack Pointer to Index X
TXA Transfer Index X to Accumulator
JMP Jump to New Location TXS Transfer Index X to Stack Pointer
JSR Jump to New Location Saving Return Address TYA Transfer Index Y to Accumulator
10 POKE 53280,0
20 POKE 53280,1
30 GOTO 10
loop: LDA #$00
STA $D020
LDA #$01
STA $D020
JMP loop
$C000 LDA #$00
$C002 STA $D020
$C005 LDA #$01
$C007 STA $D020
$C00A JMP $C000
$C000 $A9 $00
$C002 $8D $20 $D0
$C005 $A9 $01
$C007 $8D $20 $D0
$C00A $4C $00 $C0
49152 169 0
49154 141 32 208
49157 169 1
49159 141 32 208
49162 76 0 192
169 0 141 32 208 169 1 141 32 208 76 0 192
Size and speed of the program
size (b) cycles time* (µs)
$C000 LDA #$00 2 2 2.03
$C002 STA $D020 3 4 4.06
$C005 LDA #$01 2 2 2.03
$C007 STA $D020 3 4 4.06
$C00A JMP $C000 3 3 3.05
*PAL version, 0.965MHz