comparison code_part1/OSTC_code_asm_part1/i2c_eeprom.asm @ 148:055977afc2f9

Make loogbook search twice faster. + Cleanup inc/dec eeprom_address macros. + Cleanup loop menu_logbook2. + Make 2 bytes steps
author JeanDo
date Sun, 09 Jan 2011 16:04:02 +0100
parents 3e351e25f5d1
children dee88c962653
comparison
equal deleted inserted replaced
146:c09b0be2e1e6 148:055977afc2f9
17 ; last updated: 08/21/06 17 ; last updated: 08/21/06
18 ; known bugs: 18 ; known bugs:
19 ; ToDo: use 2nd 32KB from external EEPROM for something 19 ; ToDo: use 2nd 32KB from external EEPROM for something
20 20
21 incf_eeprom_address macro ext_ee_temp1 ; Will increase eeprom_address:2 with the 8Bit value "ext_ee_temp1" and takes 21 incf_eeprom_address macro ext_ee_temp1 ; Will increase eeprom_address:2 with the 8Bit value "ext_ee_temp1" and takes
22 movlw ext_ee_temp1 ; care of bank switching at 0x8000 22 movlw ext_ee_temp1 ; care of bank switching at 0x8000
23 call incf_eeprom_address0 23 call incf_eeprom_address0
24 endm 24 endm
25 25
26 incf_eeprom_address0: 26 incf_eeprom_address0:
27 movwf ext_ee_temp1 27 addwf eeprom_address+0,F ; increase address
28 incf_eeprom_address1: 28 movlw d'0'
29 movlw d'1' ; increase address 29 addwfc eeprom_address+1,F
30 addwf eeprom_address+0,F 30
31 movlw d'0' 31 btfss eeprom_address+1,7 ; at address 8000?
32 addwfc eeprom_address+1,F 32 return ; No, continue
33 btfss eeprom_address+1,7 ; at address 8000? 33
34 bra incf_eeprom_address2 ; No, continue 34 ; Yes, clear eeprom_address:2
35 35 clrf eeprom_address+0 ; Clear eeprom address
36 ; Yes, clear eeprom_address:2 36 clrf eeprom_address+1
37 clrf eeprom_address+0 ; Clear eeprom address 37 return ; Done.
38 clrf eeprom_address+1 38
39 39 ;=============================================================================
40 incf_eeprom_address2: 40 ; Will decrease eeprom_address:2 with the 8Bit value "ext_ee_temp1" and takes
41 decfsz ext_ee_temp1,F ; All done? 41 ; care of bank switching at 0x8000
42 bra incf_eeprom_address1 ; No, continue 42
43 return ; Done. 43 decf_eeprom_address macro ext_ee_temp1
44 44 movlw ext_ee_temp1
45 decf_eeprom_address macro ext_ee_temp1 ; Will decrease eeprom_address:2 with the 8Bit value "ext_ee_temp1" and takes 45 call decf_eeprom_address0
46 movlw ext_ee_temp1 ; care of bank switching at 0x8000 46 endm
47 call decf_eeprom_address0
48 endm
49 47
50 decf_eeprom_address0: 48 decf_eeprom_address0:
51 movwf ext_ee_temp1 49 subwf eeprom_address+0,F ; decrease address: do a 16-8bits substract.
52 decf_eeprom_address1: 50 movlw d'0'
53 movlw d'1' ; decrease address 51 subwfb eeprom_address+1,F
54 subwf eeprom_address+0,F 52
55 movlw d'0' 53 btfss eeprom_address+1,7 ; at address 8000?
56 subwfb eeprom_address+1,F 54 return ; No, done.
57 55
58 btfss eeprom_address+1,7 ; at address 8000? 56 movlw b'01111111' ; yes, reset highbyte
59 bra decf_eeprom_address2 ; No, continue 57 movwf eeprom_address+1
60 58 return ; Done.
61 movlw b'01111111' ; yes, reset highbyte 59
62 movwf eeprom_address+1 60 ;=============================================================================
63
64 decf_eeprom_address2:
65 decfsz ext_ee_temp1,F ; All done?
66 bra decf_eeprom_address1 ; No, continue
67 return ; Done.
68
69 61
70 write_external_eeprom: ; data in WREG 62 write_external_eeprom: ; data in WREG
71 ; increase address eeprom_address+0:eeprom_address+1 after write 63 ; increase address eeprom_address+0:eeprom_address+1 after write
72 ; with banking after 7FFF 64 ; with banking after 7FFF
73 #ifdef TESTING 65 #ifdef TESTING