-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbit_ops.s
74 lines (69 loc) · 1.07 KB
/
bit_ops.s
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
TableBit
.byt 1,2,4,8,16,32,64,128
; common code
; loads the bit number to apply/test in X and the array offset in Y
calculXY
; k is already in A lda tmp1 ; load k
lsr ; divide A by 8
lsr
lsr
tay ; offset in array
lda tmp1 ; reload k
and #%111 ; A mod 8
tax ; transfers the result to x
rts
; extern void SetBit( unsigned char A[ ], unsigned char k );
_SetBit
.(
ldy #0
lda (sp),y ; A lo
sta tmp0
iny
lda (sp),y ; A hi
sta tmp0+1
iny
lda (sp),y ; k
sta tmp1
jsr calculXY
lda (tmp0),y
ora TableBit,x
sta (tmp0),y
rts
.)
; extern void InvertBit( unsigned char A[ ], unsigned char k );
_InvertBit
.(
ldy #0
lda (sp),y ; A lo
sta tmp0
iny
lda (sp),y ; A hi
sta tmp0+1
iny
lda (sp),y ; k
sta tmp1
jsr calculXY
lda (tmp0),y
eor TableBit,x
sta (tmp0),y
rts
.)
; extern unsigned char TestBit( unsigned char A[ ], unsigned char k );
_TestBit
.(
ldy #0
lda (sp),y ; A lo
sta tmp0
iny
lda (sp),y ; A hi
sta tmp0+1
iny
lda (sp),y ; k
sta tmp1
jsr calculXY
lda (tmp0),y
and TableBit,x
tax ; result in x
lda #0 ; high byte should be 0 ?
rts
.)