-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample
55 lines (39 loc) · 820 Bytes
/
sample
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Table: dc.w S1,S2,S3,S4,
S1,S2,S3,S4,
S1,S2,S3,S4,
S1,S2,S3,S4
TB1: dc.b T1,T2,T3,T4,
T1,T2,T3,T4,
T1,T2,T3,T4,
T1,T2,T3,T4
Input (in sequence): PORTH: 0,1,2,3,8,15
Output: PORTA = ????
Begin:
ldx #Table (x <- index)
ldab PTH (b <- PTH)
andb #$0F; (b <- PTH & 0x0F)
clra (PORTA = 0)
rolb (PORTB <- PORTB * 2)
jsr[D,x] (call Table[PTH])
bra Begin
S1: movb #T1, PORTB;
jsr S5
rts
S2: movb #T2, PORTB;
jsr S5;
rts
S3: movb #T3, PORTB;
jsr S5;
rts
S4: movb #T4, PORTB;
jsr S5;
rts
S5:
lsrb (PORTB <- 2 * (PTH & 0x0f))
negb
sex B,D (D <- -PORTB)
ldx #Tbl (X <- Tbl)
leax D,x (X <- Tbl - PORTB)
ldab 15,x (PORTB <- Tbl - PORTB + 15 = Tbl[15-PORTB])
stab PORTA (PORTA <- PORTB)
rts