Have I got this right, it is a subroutine for a 6802 processor. I’m not 100% sure how the CMP works. Thanks
1. Load stack with 0x007D
2. Jump to address 7C2A
3. Load accumulator with 0x86
4. Go to subroutine 74B1
5. Add 0x10 to contents of accumulator (Now contains 0x96)
6. Push contents of A&B onto stack
7. Load memory location 1002 into accumulator B
8. Push accumulator B onto stack
9. AND accumulator A with 0x0F (Accumulator now contains 0x06 ???)
10. Compare accumulator with 0x01 (0x01 – 0x06 = 0x-05 ???)
11. 74C0 - Branch does not occur as Z flag isn’t zero ???
12. 74C7 - Branch does not occur as Z flag isn’t zero ???
13. 74C0 - Branch does not occur as Z flag isn’t zero ???
14. 74CE - Branch does not occur as Z flag isn’t zero ???
15. 74D5 - Branch does not occur as Z flag isn’t zero ???
16. 74DC - Branch does not occur as Z flag isn’t zero ???
17. 74E3 - Branch occurs as Z flag is 1 ??? (0x06 – 0x06 = 0x0)
18. 74EA – Does branch occur as accumulator is minus ???
19. 74F1 – Does branch occur as accumulator is minus ???
20. 74F8 – Does branch occur as accumulator is minus ???
21. 74FF – Does branch occur as accumulator is minus ???
22. 7506 – Does branch occur as accumulator is minus ???
23. Pull contents of stack into accumulator B
24. Store accumulator B in 1002
25. Pull contents of stack into accumulator B
26. Pull contents of stack into accumulator A
27. AND accumulator A 0xEF (accumulator now contains 0x86, back to where it started ???)
28. Return from subroutine.
Subroutine
703A : lds #$007D
703D : jmp L7C2A
7C2A : ldaa #$86
7C2C : jsr L74B1
74B1 : adda #$10
74B3 : psha
74B4 : pshb
74B5 : ldab X1002
74B8 : pshb
74B9 : staa X1002
74BC : anda #$0F
74BE : cmpa #$01
74C0 : bne L74C5
74C2 : staa X2800
74C5 : cmpa #$02
74C7 : bne L74CC
74C9 : staa X3000
74CC : cmpa #$03
74CE : bne L74D3
74D0 : staa X3800
74D3 : cmpa #$04
74D5 : bne L74DA
74D7 : staa X4000
74DA : cmpa #$05
74DC : bne L74E1
74DE : staa X4800
74E1 : cmpa #$06
74E3 : bne L74E8
74E5 : staa X5000
74E8 : cmpa #$07
74EA : bne L74EF
74EC : staa X0600
74EF : cmpa #$08
74F1 : bne L74F6
74F3 : staa X0580
74F6 : cmpa #$09
74F8 : bne L74FD
74FA : staa X0500
74FD : cmpa #$0A
74FF : bne L7504
7501 : staa X0480
7504 : cmpa #$0B
7506 : bne L750B
7508 : staa X0400
750B : pulb
750C : stab X1002
750F : pulb
7510 : pula
7511 : anda #$EF
7513 : rts
1. Load stack with 0x007D
2. Jump to address 7C2A
3. Load accumulator with 0x86
4. Go to subroutine 74B1
5. Add 0x10 to contents of accumulator (Now contains 0x96)
6. Push contents of A&B onto stack
7. Load memory location 1002 into accumulator B
8. Push accumulator B onto stack
9. AND accumulator A with 0x0F (Accumulator now contains 0x06 ???)
10. Compare accumulator with 0x01 (0x01 – 0x06 = 0x-05 ???)
11. 74C0 - Branch does not occur as Z flag isn’t zero ???
12. 74C7 - Branch does not occur as Z flag isn’t zero ???
13. 74C0 - Branch does not occur as Z flag isn’t zero ???
14. 74CE - Branch does not occur as Z flag isn’t zero ???
15. 74D5 - Branch does not occur as Z flag isn’t zero ???
16. 74DC - Branch does not occur as Z flag isn’t zero ???
17. 74E3 - Branch occurs as Z flag is 1 ??? (0x06 – 0x06 = 0x0)
18. 74EA – Does branch occur as accumulator is minus ???
19. 74F1 – Does branch occur as accumulator is minus ???
20. 74F8 – Does branch occur as accumulator is minus ???
21. 74FF – Does branch occur as accumulator is minus ???
22. 7506 – Does branch occur as accumulator is minus ???
23. Pull contents of stack into accumulator B
24. Store accumulator B in 1002
25. Pull contents of stack into accumulator B
26. Pull contents of stack into accumulator A
27. AND accumulator A 0xEF (accumulator now contains 0x86, back to where it started ???)
28. Return from subroutine.
Subroutine
703A : lds #$007D
703D : jmp L7C2A
7C2A : ldaa #$86
7C2C : jsr L74B1
74B1 : adda #$10
74B3 : psha
74B4 : pshb
74B5 : ldab X1002
74B8 : pshb
74B9 : staa X1002
74BC : anda #$0F
74BE : cmpa #$01
74C0 : bne L74C5
74C2 : staa X2800
74C5 : cmpa #$02
74C7 : bne L74CC
74C9 : staa X3000
74CC : cmpa #$03
74CE : bne L74D3
74D0 : staa X3800
74D3 : cmpa #$04
74D5 : bne L74DA
74D7 : staa X4000
74DA : cmpa #$05
74DC : bne L74E1
74DE : staa X4800
74E1 : cmpa #$06
74E3 : bne L74E8
74E5 : staa X5000
74E8 : cmpa #$07
74EA : bne L74EF
74EC : staa X0600
74EF : cmpa #$08
74F1 : bne L74F6
74F3 : staa X0580
74F6 : cmpa #$09
74F8 : bne L74FD
74FA : staa X0500
74FD : cmpa #$0A
74FF : bne L7504
7501 : staa X0480
7504 : cmpa #$0B
7506 : bne L750B
7508 : staa X0400
750B : pulb
750C : stab X1002
750F : pulb
7510 : pula
7511 : anda #$EF
7513 : rts