12F629
This commit is contained in:
parent
45002f618e
commit
00800dbaba
14
cic/mangle.c
14
cic/mangle.c
@ -58,26 +58,23 @@ void mangle(unsigned char* data) {
|
|||||||
offset &= 0xf;
|
offset &= 0xf;
|
||||||
a=x;
|
a=x;
|
||||||
a+=0xf;
|
a+=0xf;
|
||||||
CARRY
|
CARRY;
|
||||||
} while(carry);
|
} while(carry);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
unsigned char restart=1;
|
unsigned char restart=1;
|
||||||
unsigned char keyseed_orig[16]= {0x0, // dummy
|
unsigned char keyseed[16]= {0x0, // dummy
|
||||||
0xb,0x1,0x4,0xf,
|
0xb,0x1,0x4,0xf,
|
||||||
0x4,0xb,0x5,0x7,
|
0x4,0xb,0x5,0x7,
|
||||||
0xf,0xd,0x6,0x1,
|
0xf,0xd,0x6,0x1,
|
||||||
0xe,0x9,0x8};
|
0xe,0x9,0x8};
|
||||||
unsigned char lockseed_orig[16]={0x0, // dummy
|
unsigned char lockseed[16]={0x0, // dummy
|
||||||
0x0,0x9,0xa,0x1,
|
0x0,0x9,0xa,0x1,
|
||||||
0x8,0x5,0xf,0x1,
|
0x8,0x5,0xf,0x1,
|
||||||
0x1,0xe,0x1,0x0,
|
0x1,0xe,0x1,0x0,
|
||||||
0xd,0xe,0xc};
|
0xd,0xe,0xc};
|
||||||
|
|
||||||
unsigned char keyseed[16];
|
|
||||||
unsigned char lockseed[16];
|
|
||||||
|
|
||||||
printseed(keyseed);
|
printseed(keyseed);
|
||||||
printseed(lockseed);
|
printseed(lockseed);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@ -85,6 +82,7 @@ int main(void) {
|
|||||||
while(1) {
|
while(1) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printstream(keyseed, restart);
|
printstream(keyseed, restart);
|
||||||
|
printstream(lockseed, restart);
|
||||||
mangle(keyseed);
|
mangle(keyseed);
|
||||||
mangle(keyseed);
|
mangle(keyseed);
|
||||||
mangle(keyseed);
|
mangle(keyseed);
|
||||||
@ -94,8 +92,8 @@ while(1) {
|
|||||||
|
|
||||||
// printseed(keyseed);
|
// printseed(keyseed);
|
||||||
// printseed(lockseed);
|
// printseed(lockseed);
|
||||||
restart=lockseed[3];
|
restart=lockseed[7];
|
||||||
lockseed[3]=lockseed[7];
|
// lockseed[3]=lockseed[7];
|
||||||
if(!restart)restart=1;
|
if(!restart)restart=1;
|
||||||
// printf("send %d-15\n", restart);
|
// printf("send %d-15\n", restart);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
#include <p12f683.inc>
|
#include <p12f629.inc>
|
||||||
processor p12f683
|
processor p12f629
|
||||||
|
|
||||||
; -----------------------------------------------------------------------
|
; -----------------------------------------------------------------------
|
||||||
__CONFIG _EC_OSC & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOD_ON & _IESO_ON & _FCMEN_ON
|
__CONFIG _EC_OSC & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF
|
||||||
|
|
||||||
; -----------------------------------------------------------------------
|
; -----------------------------------------------------------------------
|
||||||
; code memory
|
; code memory
|
||||||
@ -29,15 +29,14 @@ init
|
|||||||
org 0x0010
|
org 0x0010
|
||||||
banksel GPIO
|
banksel GPIO
|
||||||
clrf GPIO
|
clrf GPIO
|
||||||
movlw 0x17 ; GPIO4, GPIO2, GPIO1, GPIO0 are digital I/O
|
movlw 0x07 ; GPIO2..0 are digital I/O (not connected to comparator)
|
||||||
movwf CMCON0
|
movwf CMCON
|
||||||
movlw 0x90 ; Enable interrupts + enable INT
|
movlw 0x90 ; Enable interrupts + enable INT
|
||||||
movwf INTCON
|
movwf INTCON
|
||||||
banksel ANSEL
|
banksel TRISIO
|
||||||
clrf ANSEL
|
|
||||||
movlw 0x2e ; in out in in in out
|
movlw 0x2e ; in out in in in out
|
||||||
movwf TRISIO
|
movwf TRISIO
|
||||||
movlw 0x80 ; 0x3f for pullups
|
movlw 0x80 ; 0x00 for pullups
|
||||||
movwf OPTION_REG
|
movwf OPTION_REG
|
||||||
banksel GPIO
|
banksel GPIO
|
||||||
bsf GPIO, 0x0
|
bsf GPIO, 0x0
|
||||||
@ -50,7 +49,6 @@ main
|
|||||||
bsf TRISIO, 1
|
bsf TRISIO, 1
|
||||||
bcf TRISIO, 0
|
bcf TRISIO, 0
|
||||||
banksel GPIO
|
banksel GPIO
|
||||||
; sleep
|
|
||||||
;--------INIT KEY SEED--------
|
;--------INIT KEY SEED--------
|
||||||
movlw 0xb
|
movlw 0xb
|
||||||
movwf 0x21
|
movwf 0x21
|
||||||
@ -287,31 +285,31 @@ mangle_key_withoutskip
|
|||||||
|
|
||||||
movf 0x28, w ;
|
movf 0x28, w ;
|
||||||
addlw 0x1 ;inc
|
addlw 0x1 ;inc
|
||||||
addwf 0x29, f ;add to 28
|
addwf 0x29, f ;add to 29
|
||||||
|
|
||||||
movf 0x29, w ;
|
movf 0x29, w ;
|
||||||
addlw 0x1 ;inc
|
addlw 0x1 ;inc
|
||||||
addwf 0x2a, f ;add to 28
|
addwf 0x2a, f ;add to 2a
|
||||||
|
|
||||||
movf 0x2a, w ;
|
movf 0x2a, w ;
|
||||||
addlw 0x1 ;inc
|
addlw 0x1 ;inc
|
||||||
addwf 0x2b, f ;add to 28
|
addwf 0x2b, f ;add to 2b
|
||||||
|
|
||||||
movf 0x2b, w ;
|
movf 0x2b, w ;
|
||||||
addlw 0x1 ;inc
|
addlw 0x1 ;inc
|
||||||
addwf 0x2c, f ;add to 28
|
addwf 0x2c, f ;add to 2c
|
||||||
|
|
||||||
movf 0x2c, w ;
|
movf 0x2c, w ;
|
||||||
addlw 0x1 ;inc
|
addlw 0x1 ;inc
|
||||||
addwf 0x2d, f ;add to 28
|
addwf 0x2d, f ;add to 2d
|
||||||
|
|
||||||
movf 0x2d, w ;
|
movf 0x2d, w ;
|
||||||
addlw 0x1 ;inc
|
addlw 0x1 ;inc
|
||||||
addwf 0x2e, f ;add to 28
|
addwf 0x2e, f ;add to 2e
|
||||||
|
|
||||||
movf 0x2e, w ;
|
movf 0x2e, w ;
|
||||||
addlw 0x1 ;inc
|
addlw 0x1 ;inc
|
||||||
addwf 0x2f, f ;add to 28
|
addwf 0x2f, f ;add to 2f
|
||||||
;60
|
;60
|
||||||
movf 0x20, w ;restore original 0xf
|
movf 0x20, w ;restore original 0xf
|
||||||
andlw 0xf
|
andlw 0xf
|
||||||
@ -331,17 +329,18 @@ mangle_key_withoutskip
|
|||||||
nop
|
nop
|
||||||
goto mangle_key_loop
|
goto mangle_key_loop
|
||||||
; 69 when goto, 69 when return
|
; 69 when goto, 69 when return
|
||||||
; CIC has 78
|
; CIC has 78 -> 9 nops
|
||||||
|
|
||||||
mangle_key_withskip
|
mangle_key_withskip
|
||||||
movf 0x41, w ;restore 23
|
movf 0x41, w ;restore 23
|
||||||
addwf 0x23, f ;add to 23
|
addwf 0x23, f ;add to 23
|
||||||
movf 0x24, w
|
movf 0x24, w
|
||||||
movwf 0x40 ;save 25 to 40
|
movwf 0x40 ;save 24 to 40
|
||||||
movf 0x23, w
|
movf 0x23, w
|
||||||
addwf 0x24, f
|
addwf 0x24, f
|
||||||
movf 0x25, w
|
movf 0x25, w
|
||||||
movwf 0x41 ;save 26 to 41
|
movwf 0x41 ;save 25 to 41
|
||||||
movf 0x40, w ;restore 25
|
movf 0x40, w ;restore 24
|
||||||
andlw 0xf ;mask nibble
|
andlw 0xf ;mask nibble
|
||||||
addlw 0x8 ;add #8 to HIGH nibble
|
addlw 0x8 ;add #8 to HIGH nibble
|
||||||
movwf 0x40
|
movwf 0x40
|
||||||
@ -349,13 +348,13 @@ mangle_key_withskip
|
|||||||
addwf 0x25, w
|
addwf 0x25, w
|
||||||
movwf 0x25
|
movwf 0x25
|
||||||
|
|
||||||
movf 0x41, w ;restore 26
|
movf 0x41, w ;restore 25
|
||||||
addlw 0x1 ;inc
|
addlw 0x1 ;inc
|
||||||
addwf 0x26, f ;add to 27
|
addwf 0x26, f ;add to 26
|
||||||
|
|
||||||
movf 0x26, w ;
|
movf 0x26, w ;
|
||||||
addlw 0x1 ;inc
|
addlw 0x1 ;inc
|
||||||
addwf 0x27, f ;add to 28
|
addwf 0x27, f ;add to 27
|
||||||
|
|
||||||
movf 0x27, w ;
|
movf 0x27, w ;
|
||||||
addlw 0x1 ;inc
|
addlw 0x1 ;inc
|
||||||
@ -363,31 +362,31 @@ mangle_key_withskip
|
|||||||
|
|
||||||
movf 0x28, w ;
|
movf 0x28, w ;
|
||||||
addlw 0x1 ;inc
|
addlw 0x1 ;inc
|
||||||
addwf 0x29, f ;add to 28
|
addwf 0x29, f ;add to 29
|
||||||
|
|
||||||
movf 0x29, w ;
|
movf 0x29, w ;
|
||||||
addlw 0x1 ;inc
|
addlw 0x1 ;inc
|
||||||
addwf 0x2a, f ;add to 28
|
addwf 0x2a, f ;add to 2a
|
||||||
|
|
||||||
movf 0x2a, w ;
|
movf 0x2a, w ;
|
||||||
addlw 0x1 ;inc
|
addlw 0x1 ;inc
|
||||||
addwf 0x2b, f ;add to 28
|
addwf 0x2b, f ;add to 2b
|
||||||
|
|
||||||
movf 0x2b, w ;
|
movf 0x2b, w ;
|
||||||
addlw 0x1 ;inc
|
addlw 0x1 ;inc
|
||||||
addwf 0x2c, f ;add to 28
|
addwf 0x2c, f ;add to 2c
|
||||||
|
|
||||||
movf 0x2c, w ;
|
movf 0x2c, w ;
|
||||||
addlw 0x1 ;inc
|
addlw 0x1 ;inc
|
||||||
addwf 0x2d, f ;add to 28
|
addwf 0x2d, f ;add to 2d
|
||||||
|
|
||||||
movf 0x2d, w ;
|
movf 0x2d, w ;
|
||||||
addlw 0x1 ;inc
|
addlw 0x1 ;inc
|
||||||
addwf 0x2e, f ;add to 28
|
addwf 0x2e, f ;add to 2e
|
||||||
|
|
||||||
movf 0x2e, w ;
|
movf 0x2e, w ;
|
||||||
addlw 0x1 ;inc
|
addlw 0x1 ;inc
|
||||||
addwf 0x2f, f ;add to 28
|
addwf 0x2f, f ;add to 2f
|
||||||
;64
|
;64
|
||||||
movf 0x20, w ;restore original 0xf
|
movf 0x20, w ;restore original 0xf
|
||||||
andlw 0xf
|
andlw 0xf
|
||||||
@ -411,7 +410,7 @@ mangle_key_withskip
|
|||||||
mangle_return
|
mangle_return
|
||||||
return
|
return
|
||||||
;73 when goto, 73 when return
|
;73 when goto, 73 when return
|
||||||
;CIC has 84
|
;CIC has 84 -> 11 nops
|
||||||
|
|
||||||
mangle_lock
|
mangle_lock
|
||||||
movf 0x3f, w
|
movf 0x3f, w
|
||||||
@ -506,7 +505,7 @@ mangle_lock_withoutskip
|
|||||||
nop
|
nop
|
||||||
goto mangle_lock_loop
|
goto mangle_lock_loop
|
||||||
; 69 when goto, 69 when return
|
; 69 when goto, 69 when return
|
||||||
; CIC has 78
|
; CIC has 78 -> 9 nops
|
||||||
|
|
||||||
mangle_lock_withskip
|
mangle_lock_withskip
|
||||||
movf 0x41, w ;restore 33
|
movf 0x41, w ;restore 33
|
||||||
@ -585,7 +584,7 @@ mangle_lock_withskip
|
|||||||
nop
|
nop
|
||||||
goto mangle_lock_loop
|
goto mangle_lock_loop
|
||||||
;73 when goto, 73 when return
|
;73 when goto, 73 when return
|
||||||
;CIC has 84
|
;CIC has 84 -> 11 nops
|
||||||
|
|
||||||
;--------wait: 3*(W-1)+7 cycles (including call+return). W=0 -> 256!--------
|
;--------wait: 3*(W-1)+7 cycles (including call+return). W=0 -> 256!--------
|
||||||
wait
|
wait
|
||||||
@ -638,6 +637,7 @@ die_intloop
|
|||||||
bsf INTCON, GIE
|
bsf INTCON, GIE
|
||||||
|
|
||||||
banksel GPIO
|
banksel GPIO
|
||||||
|
;--------forever: blink status pin--------
|
||||||
die_blink
|
die_blink
|
||||||
clrw
|
clrw
|
||||||
call longwait
|
call longwait
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user