BYTE 5.1 PG 56 A computer controlled light dimmer Part 1 BYTE 5.2 PG 72 A computer controlled light dimmer Part 2 BYTE 4.10 PG 202 addr value of address label or absolute address adrr =addr-2-PC, relitive address im byte immediate fp byte offset in first page memory imwd =im,im word immediate xx =im index offset a accumulator registor 0 A 1 B mm memory address mode 00 immediate op #<immediate value> 01 first page op <address in first page> 10 index op <offset>,X 11 absolute op <absolute address> d direction 0 load 1 store maop Math Operation 0000 SUB 0001 CMP 0100 AND 0101 BIT 0110 LDA 0111 STA 1000 EOR 1001 ADC 1010 ORA 1011 ADD 1100 CPX PC program counter register A First accumulator register B second accumulator register X index register P CCR Condition Code Register H Half carry 5 I Interrupt mask 4 N Negative 3 Z Zero 2 V oVerflow 1 C Carry 0 S Stack pointer register 01 NOP 02 03 04 05 06 TAP ;P=A Transfer to CCR 07 TPA ;A=P Transfer from CCR 08 INX ;Increment X, Compare with 0? 09 DEX ;Decrement X, Compare with 0? 0A CLV ;Clear Overflow 0B SEV ;Set Overflow 0C CLC ;Clear Carry 0D SEC ;Set Carry 0E CLI ;Clear IRQ Mask 0F SEI ;Set IRQ Mask 16 TAB ;Transfer A to B? 17 TBA ;Transfer B to A 18 ;? 19 DAA ;Decimal adjust accumulator 1B ABA ;A=A+B Add accumulators 20 ar BRA adrr ; Skip (Branch Always) 21 ar BRN adrr ; Branch Never 22 ar BHI adrr ;C|Z=0? Branch Higher 23 ar BLS adrr ;C|Z=1? Branch Lower or Same 24 ar BCC adrr ;C=0? Branch Carry Clear 25 ar BCS adrr ;C=1? Branch Carry Set 26 ar BNE adrr ;Z=1? Branch Not Equal 27 ar BEQ adrr ;Branch Equal 28 ar BVC adrr ;Branch oVerflow Clear 29 ar BVS adrr ;Branch Half Carry Set 2A ar BPL adrr ;N=0? Branch Plus 2B ar BM1 adrr ;N=1? Branch Minus 2C ar BGE adrr ;N^V=0? Branch Greater than or Equal 2D ar BLT adrr ;N^V=1? Branch Less Than 2E ar BGT adrr ;Z|{N^V}=0? !Z&!{N^V}=1? Branch Greater than 2F ar BLE adrr ;Z|{N^V}=1? Branch Less than or Equal 32 PUL A 33 PUL B 34 DES ;Decrement Stack, Compare with 0? 35 36 PSH A 37 PSH B 38 39 RTS ;RETURN 3A 3B RTI ;Return from interrupt? 80 12 SUB A #18 90 A0 B0 81 im CMP A im 91 fp CMP A fp A1 xx CMP A xx,X B1 addr CMP A addr C1 im CMP B im D1 fp CMP B fp E1 xx CMP B xx,X F1 addr CMP B addr 1amm 0100 84 im AND A im ;A=A&im And A with immediate byte 94 fp AND A fp ;A=A&(fp) And A with first page memory byte at immediate byte A4 xx AND A xx,X ;A=A&(xx+X) And A with memory byte at X+byte offset B4 addr AND A addr ;A=A&(addr) And A with memory byte at addr C4 im AND B im ;B=B&im And B with immediate byte D4 fp AND B fp ;B=B&(fp) And B with first page memory byte at immediate byte E4 xx AND B xx,X ;B=B&(xx+X) And B with memory byte at X+byte offset F4 addr AND B addr ;B=B&(addr) And B with memory byte at addr 1amm 0101 85 im BIT A im ;A&im Bit test 95 fp BIT A fp ;A&(fp) A5 xx BIT A xx,X ;A&(xx+X) B5 addr BIT A addr ;A&(addr) C5 im BIT B im ;B&im D5 fp BIT B fp ;B&(fp) E5 xx BIT B xx,X ;B&(xx+X) F5 addr BIT B addr ;B&(addr) 1amm 011d ; Load Accumulator register 86 3F LDA A #$3F ;Load A byte immediate 96 20 LDA A RNDM ;Load A with byte memory at first page address byte immediate A6 00 LDA A 0,X ;Load A with byte memory at X+byte immediate B6 A000 LDA A ASSA ;Load A with byte memory at word immediate C6 18 LDA B $24 ;Load B byte immediate (24d is 18h) D6 20 LDA B RNDM ;Load B with byte memory at first page address byte immediate E6 00 LDA B 0,X ;Load B with byte memory at X+byte immediate F6 A000 LDA B ASSA ;Load B with byte memory at word immediate 87 ; not used? 97 22 STA A RNDM+2 ;Store A in first page memory address byte immediate (RNDM is at address 20 in first page) A7 00 STA A 0,X ;Store A in memory at X+byte immediate B7 ; not used? C7 ; not used? D7 22 STA B RNDM+2 ;Store B in first page memory address byte immediate (RNDM is at address 20 in first page) E7 02 STA B 2,X ;Store B in memory at X+byte immediate F7 ; not used? 88 98 20 EOR A RNDM ;XOR A8 B8 C8 D8 E8 F8 1amm 1001 89 im ADC A im ;A=A+im+C Add A with Carry to immediate byte 99 fp ADC A fp ;A=A+(fp)+C Add A with Carry to first page memory byte at immediate byte A9 xx ADC A xx,X ;A=A+(xx+X)+C Add A with Carry to memory byte at X+byte offset B9 addr ADC A addr ;A=A+(addr)+C Add A with Carry to memory byte at addr C9 im ADC B im ;B=B+im+C Add B with Carry to immediate byte D9 fp ADC B fp ;B=B+(fp)+C Add B with Carry to first page memory byte at immediate byte E9 xx ADC B xx,X ;B=B+(xx+X)+C Add B with Carry to memory byte at X+byte offset F9 addr ADC B addr ;B=B+(addr)+C Add B with Carry to memory byte at addr 1amm 1010 8A im ORA A im ;A=A|im ORA with byte immediate 9A fp ORA A fp ;A=A|(fp) ORA with byte in first page address AA xx ORA A xx,X ;A=A|(xx+X) ORA with byte at X+byte offset BA addr ORA A addr ;A=A|(addr) ORA with byte at memory address word immediate CA im ORA B im ;B=B|im ORB with byte immediate DA fp ORA B fp ;B=B|(fp) ORB with byte in first page address EA xx ORA B xx,X ;B=B|(xx+X) ORB with byte at X+byte offset FA addr ORA B addr ;B=B|(addr) ORB with byte at memory address word immediate 1amm 1011 8B im ADD A im ;A=A+im Add A to immediate byte 9B fp ADD A fp ;A=A+(fp) Add A to first page memory byte at immediate byte AB xx ADD A xx,X ;A=A+(xx+X) Add A to memory byte at X+byte offset BB addr ADD A addr ;A=A+(addr) Add A to memory byte at addr CB im ADD B im ;B=B+im Add B to immediate byte DB fp ADD B fp ;B=B+(fp) Add B to first page memory byte at immediate byte EB xx ADD B xx,X ;B=B+(xx+X) Add B to memory byte at X+byte offset FB addr ADD B addr ;B=B+(addr) Add B to memory byte at addr 8C 0013 CPX #$13 ; 9C 75 CPX SaveSum ;SaveSum equates to 75 AC BC CC DC EC FC 8D os BSR <PC-addr> ;(S--)=PC, PC=PC+2+os Branch to Service Routine at PC+offset+2 9D ;? AD xx JSR xx,X ;(S--)=PC, PC=X+xx Jump to Service Routine at indeX plus immediate byte BD 012C JSR addr RANDOM ;(S--)=PC, PC=addr Jump to Service Routine at immediate word (CALL) RANDOM is at address 012C CD DD ED FD 1pmm 111d ; Load Pointer register p=Stack/Index mm=Immediate/FirstPage/Index/Address d=Load/Store 8E 8004 LDS #PIAD ;Load Stack pointer with immediate word 9E 56 LDS fp WTBLRP ;Load Stack pointer with first page memory word at byte immediate AE xx LDS xx,X ;Load Stack pointer with memory word at indeX plus byte immediate BE A000 LDS addr ASSA ;Load Stack pointer with memory word at word immediate CE 8004 LDX #PIAD ;Load indeX with immediate word DE 23 LDX fp TBLADR ;Load indeX with word memory at byte immediate in first page (TBLADR is at address 0023 in first page) EE xx LDX xx,X ;Load indeX with word memory at indeX plus byte immediate FE A000 LDX addr ASSA ;Load indeX with word memory at word immediate 8F STS ? ; 9F 56 STS fp WTBLRP ;Store Stack pointer in first page memory address byte immediate (WTBLRP is at address 56 in first page) AF xx STS xx,X ;Store Stack pointer in memory word at indeX plus byte immediate BF addr STS addr ;Store Stack pointer in memory word at word immediate CF 8004 STX #PIAD ? ; DF 23 STX fp TBLADR ;Store indeX in memory word at first page memory address plus byte immediate (TBLADR is at address 23 in first page) EF xx STX xx,X ;Store indeX in memory word at indeX plus byte immediate FF A000 STX addr ASSA ;Store indeX in memory word at word immediate 40 NEG A ;? 50 NEG B 60 70 41 51 61 71 42 52 62 72 43 COM A ;Complement A 53 63 73 44 COM MPTPAT 44 LSR A ;Logical Shift Right 54 LSR B ;Shift right 64 xx LSR xx,X 74 addr LSR addr 45 ASR A ;Arithmetic Shift Right 55 ASR B 65 xx ASR xx,X 75 addr ASR addr 46 ROR A 56 ROR B 66 00 ROR 0,X 76 0022 ROR RNDM+2 47 ASR A ;A=A/2 Arithmetic Shift Right 57 ASR B ;B=B/2 67 xx ASR xx,X ;(xx+X)=(xx+X)/2 77 addr ASR addr ;(addr)=(addr)/2 48 ASL A ;A=A*2 Arithmetic Shift Left 58 ASL B ;B=B*2 68 xx ASL xx,X ;(xx+X)=(xx+X)*2 78 addr ASL addr ;(addr)=(addr)*2 49 ROL A ;A=A<< 59 ROL B 69 xx ROL xx,X 79 addr ROL addr 4A DEC A 5A DEC B 6A 02 DEC 2,X 7A XXXX DEC (XXXX) ;? 4B 5B 6B 7B 4C INC A ;? 5C INC B 6C 02 INC 2,X 7C 8006 INC PIA 4D TST A ; 5D TST B ; 6D 02 TST 2,X ; 7D XXXX TST (XXXX) ;GOOD 4E 5E 6E 7E 0100 JMP START 4F CLR A 5F CLR B 6F 02 CLR 2,X ; 7F 49 CLR ENDGAM ;ENDGAM is at 49 in first page