-
Notifications
You must be signed in to change notification settings - Fork 85
/
signature.src
82 lines (66 loc) · 1.14 KB
/
signature.src
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
74
75
76
77
78
79
80
81
82
.page
.subttl "signature.src'
; test 256k-bit of rom
; using signature generation test bits 15, 11, 8, 6
; exit if ok
signature
php
sei ; no irqs
ldx #0
stx $00 ; sig_lo
stx $01 ; sig_hi
lda #3 ; skip checksum & signature bytes
sta ip ; even page
tay
lda #$80 ; start at $8000
sta ip+1 ; high order
2$ lda (ip),y ; get a byte
sta $02
ldx #8 ; 8 bits in a byte right?
3$ lda $02
and #1 ; bit 0
sta $03
lda $01 ; get sig_hi
bpl 4$ ; test bit 15
inc $03
4$ ror a
bcc 5$ ; test bit 8
inc $03
5$ ror a
ror a
ror a
bcc 6$
inc $03
6$ lda $00 ; sig_lo
rol a
rol a
bcc 7$ ; test bit 6
inc $03
7$ ror $03 ; sum into carry
rol $00 ; carry into bit 0 low byte
rol $01 ; carry into bit 0 high byte
ror $02 ; ready for next bit
dex
bne 3$
inc ip
bne 2$
inc ip+1 ; next page
bne 2$
dey
dey
dey ; .y = 0
lda $00
cmp signature_lo
bne sig_err
lda $01
cmp signature_hi
bne sig_err
sty $00 ; clear
sty $01
sty $02
sty $03
plp
rts
sig_err ldx #3 ; 4 blinks
stx temp
jmp perr ; bye bye ....