Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/math.asm @ 842:454ef5c2e6aa default tip
Bugfix: Auto-SP did not show >9m for some 2C hardware versions in German language firmware
Make year settings until 2040 possible (This is likely the final release for this model)
| author | heinrichsweikamp |
|---|---|
| date | Sat, 29 Nov 2025 14:11:07 +0100 |
| parents | 2a0e5d884fc3 |
| children |
| rev | line source |
|---|---|
| 815 | 1 ; OSTC Mk.2, 2N and 2C - diving computer code |
|
807
c50296c3059e
BUGFIX: Divetime had unwanted "." behind the minutes
heinrichsweikamp
parents:
577
diff
changeset
|
2 ; Copyright (C) 2015 HeinrichsWeikamp GbR |
| 0 | 3 |
| 4 ; This program is free software: you can redistribute it and/or modify | |
| 5 ; it under the terms of the GNU General Public License as published by | |
| 6 ; the Free Software Foundation, either version 3 of the License, or | |
| 7 ; (at your option) any later version. | |
| 8 | |
| 9 ; This program is distributed in the hope that it will be useful, | |
| 10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 ; GNU General Public License for more details. | |
| 13 | |
| 14 ; You should have received a copy of the GNU General Public License | |
| 15 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 16 | |
| 17 | |
| 18 ; Math routines | |
|
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
19 ; history: |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
20 ; 2005-10-30: Written by Matthias Heinrichs, info@heinrichsweikamp.com |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
21 ; 2007-06-21: MH last updated |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
22 ; 2011-01-19: Clean up of isr variante. |
| 0 | 23 ; known bugs: |
| 24 ; ToDo: clean up! | |
| 25 | |
| 88 | 26 |
| 0 | 27 convert_time: ; converts hi:lo in minutes to hours (hi) and minutes (lo) |
| 28 movff lo,xA+0 ; divide by 60... | |
| 29 movff hi,xA+1 ; | |
| 30 movlw d'60' ; | |
| 31 movwf xB+0 ; | |
| 32 clrf xB+1 ; | |
| 33 rcall div16x16 ; xA/xB=xC with xA as remainder | |
| 34 movff xC+0,hi ; Hours | |
| 35 movff xA+0,lo ; =remaining minutes (0.....59) | |
| 36 return | |
| 37 | |
| 38 div16: | |
| 39 ; divA=divA/2^divB (divB: 8Bit only!) | |
| 40 bcf STATUS,C | |
| 41 rrcf divA+1 | |
| 42 rrcf divA | |
| 43 decfsz divB | |
| 44 bra div16 | |
| 45 return | |
| 46 | |
| 544 | 47 sub16: ; sub_c = sub_a - sub_b (with signed values) |
| 0 | 48 bcf neg_flag |
| 74 | 49 movf sub_b+0, W ; Get Value to be subtracted |
| 50 subwf sub_a+0, W ; Do the High Byte | |
| 51 movwf sub_c+0 | |
| 52 movf sub_b+1, W ; Get the Value to be Subbed | |
| 53 subwfb sub_a+1, W | |
| 54 movwf sub_c+1 | |
|
342
06299199dfb9
Fix bad max depth value (fix sub16 to avoid trashing sub_b).
JeanDo
parents:
161
diff
changeset
|
55 |
| 354 | 56 btfss STATUS,N ; Negativ result ? |
| 57 return ; NO: result positive done. | |
|
342
06299199dfb9
Fix bad max depth value (fix sub16 to avoid trashing sub_b).
JeanDo
parents:
161
diff
changeset
|
58 |
| 354 | 59 bsf neg_flag ; MARK result negative |
|
342
06299199dfb9
Fix bad max depth value (fix sub16 to avoid trashing sub_b).
JeanDo
parents:
161
diff
changeset
|
60 |
|
06299199dfb9
Fix bad max depth value (fix sub16 to avoid trashing sub_b).
JeanDo
parents:
161
diff
changeset
|
61 comf sub_c+1 ; 16bit sign change. |
|
06299199dfb9
Fix bad max depth value (fix sub16 to avoid trashing sub_b).
JeanDo
parents:
161
diff
changeset
|
62 negf sub_c+0 |
|
06299199dfb9
Fix bad max depth value (fix sub16 to avoid trashing sub_b).
JeanDo
parents:
161
diff
changeset
|
63 btfsc STATUS,C ; Carry to propagate ? |
|
06299199dfb9
Fix bad max depth value (fix sub16 to avoid trashing sub_b).
JeanDo
parents:
161
diff
changeset
|
64 incf sub_c+1,F ; YES: do it. |
|
06299199dfb9
Fix bad max depth value (fix sub16 to avoid trashing sub_b).
JeanDo
parents:
161
diff
changeset
|
65 |
| 0 | 66 return |
| 67 | |
| 544 | 68 subU16: ; sub_c = sub_a - sub_b (with UNSIGNED values) |
| 426 | 69 bcf neg_flag |
| 70 movf sub_b+0, W ; Get Value to be subtracted | |
| 71 subwf sub_a+0, W ; Do the High Byte | |
| 72 movwf sub_c+0 | |
| 73 movf sub_b+1, W ; Get the Value to be Subbed | |
| 74 subwfb sub_a+1, W | |
| 75 movwf sub_c+1 | |
| 76 | |
| 77 btfsc STATUS,C ; Borrow to propagate ? (B == /CARRY) | |
| 78 return ; NO: result positive done. | |
| 79 | |
| 80 bsf neg_flag ; MARK result negative | |
| 81 | |
| 82 comf sub_c+1 ; 16bit sign change. | |
| 83 negf sub_c+0 | |
| 84 btfsc STATUS,C ; Carry to propagate ? | |
| 85 incf sub_c+1,F ; YES: do it. | |
| 86 | |
| 87 return | |
| 88 | |
| 476 | 89 ;============================================================================= |
| 90 | |
| 105 | 91 mult16x16: ;xA*xB=xC |
| 0 | 92 clrf xC+2 ; Clear the High-Order Bits |
| 93 clrf xC+3 | |
| 94 movf xA, w ; Do the "L" Multiplication first | |
| 95 mulwf xB | |
| 96 movf PRODL, w ; Save result | |
| 97 movwf xC | |
| 98 movf PRODH, w | |
| 99 movwf xC+1 | |
| 100 movf xA, w ; Do the "I" Multiplication | |
| 101 mulwf xB+1 | |
| 102 movf PRODL, w ; Save the Most Significant Byte First | |
| 103 addwf xC+1, f | |
| 104 movf PRODH, w | |
| 105 addwfc xC+2, f ; Add to the Last Result | |
| 106 movf xA+1, w ; Do the "O" Multiplication | |
| 107 mulwf xB | |
| 108 movf PRODL, w ; Add the Lower Byte Next | |
| 109 addwf xC+1, f | |
| 110 movf PRODH, w ; Add the High Byte First | |
| 111 addwfc xC+2, f | |
| 112 btfsc STATUS, C ; Add the Carry | |
| 113 incf xC+3, f | |
| 114 movf xA+1, w ; Do the "F" Multiplication | |
| 115 mulwf xB+1 | |
| 116 movf PRODL, w | |
| 117 addwf xC+2, f | |
| 118 movf PRODH, w | |
| 119 addwfc xC+3, f | |
| 120 return | |
| 121 | |
| 476 | 122 ;============================================================================= |
| 0 | 123 |
| 124 div16x16: ;xA/xB=xC with xA as remainder | |
| 125 ;uses divB as temp variable | |
| 126 clrf xC+0 | |
| 127 clrf xC+1 | |
| 128 MOVF xB+0,W ; Check for zero | |
| 129 IORWF xB+1,W ; | |
| 130 BTFSC STATUS,Z ; Check for zero | |
| 131 RETLW H'FF' ; return 0xFF if illegal | |
| 132 MOVLW 1 ; Start count at 1 | |
| 133 MOVWF divB ; Clear Count | |
| 134 div16x16_1 | |
| 135 BTFSC xB+1,7 ; High bit set ? | |
| 136 bra div16x16_2 ; Yes then continue | |
| 137 INCF divB,F ; Increment count | |
| 138 | |
| 139 bcf STATUS,C | |
| 140 rlcf xB+0,F | |
| 141 rlcf xB+1,F | |
| 142 bra div16x16_1 | |
| 143 div16x16_2: | |
| 144 ; Shift result left | |
| 145 bcf STATUS,C | |
| 146 rlcf xC+0,F | |
| 147 rlcf xC+1,F | |
| 148 | |
| 149 ; Reduce Divisor | |
| 150 | |
| 151 MOVF xB,W ; Get low byte of subtrahend | |
| 152 SUBWF xA,F ; Subtract DST(low) - SRC(low) | |
| 153 MOVF xB+1,W ; Now get high byte of subtrahend | |
| 154 BTFSS STATUS,C ; If there was a borrow, rather than | |
| 155 INCF xB+1,W ; decrement high byte of dst we inc src | |
| 156 SUBWF xA+1,F ; Subtract the high byte and we're done | |
| 157 | |
| 158 | |
| 159 BTFSC STATUS, C ; Did it reduce? | |
| 160 bra div16x16_3 ; No, so it was less than | |
| 161 | |
| 162 movf xB+0,W ; Reverse subtraction | |
| 163 addwf xA+0,F | |
| 164 movf xB+1,W | |
| 165 addwfc xA+1,F | |
| 166 | |
| 167 bra div16x16_4 ; Continue the process | |
| 168 div16x16_3: | |
| 169 BSF xC+0,0 ; Yes it did, this gets a 1 bit | |
| 170 div16x16_4: | |
| 171 DECF divB,F ; Decrement N_COUNT | |
| 172 BTFSC STATUS,Z ; If its not zero then continue | |
| 173 return | |
| 174 | |
| 175 bcf STATUS,C | |
| 176 rrcf xB+1,F | |
| 177 rrcf xB+0,F | |
| 178 | |
| 179 bra div16x16_2 ; Next bit. | |
| 180 | |
| 476 | 181 ;============================================================================= |
| 182 | |
| 0 | 183 div32x16: ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder |
| 184 ; Setup | |
| 185 movlw .32 ; setup shift counter | |
| 186 movwf divB | |
| 187 movf xC+3,W ; move ACCb to ACCf | |
| 188 movwf xA+1 | |
| 189 movf xC+2,W | |
| 190 movwf xA+0 | |
| 191 movf xC+1,W ; move ACCc to ACCe | |
| 192 movwf sub_a+1 | |
| 193 movf xC+0,W | |
| 194 movwf sub_a+0 | |
| 195 clrf xC+3 | |
| 196 clrf xC+2 | |
| 197 clrf xC+1 | |
| 198 clrf xC+0 | |
| 199 clrf sub_b+1 | |
| 200 clrf sub_b+0 | |
| 201 div32x16_2 | |
| 202 bcf STATUS,C | |
| 203 rlcf sub_a+0,F | |
| 204 rlcf sub_a+1,F | |
| 205 rlcf xA+0,F | |
| 206 rlcf xA+1,F | |
| 207 rlcf sub_b+0,F | |
| 208 rlcf sub_b+1,F | |
| 209 movf xB+1,W | |
| 210 subwf sub_b+1,W ; check if a>d | |
| 211 btfss STATUS,Z | |
| 476 | 212 bra div32x16_3 |
| 0 | 213 movf xB+0,W |
| 214 subwf sub_b+0,W ; if msb equal then check lsb | |
| 215 div32x16_3 | |
| 216 btfss STATUS,C ; carry set if d>a | |
| 476 | 217 bra div32x16_4 |
| 0 | 218 movf xB+0,W ; d-a into d |
| 219 subwf sub_b+0,F | |
| 220 btfss STATUS,C | |
| 221 decf sub_b+1,F | |
| 222 movf xB+1,W | |
| 223 subwf sub_b+1,F | |
| 224 bsf STATUS,C ; shift a 1 into b (result) | |
| 225 div32x16_4 | |
| 226 rlcf xC+0,F | |
| 227 rlcf xC+1,F | |
| 228 rlcf xC+2,F | |
| 229 rlcf xC+3,F | |
| 230 decfsz divB,F ; loop until all bits checked | |
| 476 | 231 bra div32x16_2 |
| 0 | 232 return |
| 233 | |
|
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
234 ;============================================================================= |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
235 ; u16 * u16 --> 32bit multiply (xA * xB --> xC) |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
236 ; Used in interupt service routines, to compute temperature and pressure. |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
237 ; |
| 0 | 238 isr_mult16x16: |
| 239 clrf isr_xC+2 ; Clear the High-Order Bits | |
| 240 clrf isr_xC+3 | |
| 241 movf isr_xA, w ; Do the "L" Multiplication first | |
| 242 mulwf isr_xB | |
| 243 movf PRODL, w ; Save result | |
|
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
244 movwf isr_xC+0 |
| 0 | 245 movf PRODH, w |
| 246 movwf isr_xC+1 | |
|
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
247 movf isr_xA+0, w ; Do the "I" Multiplication |
| 0 | 248 mulwf isr_xB+1 |
| 249 movf PRODL, w ; Save the Most Significant Byte First | |
| 250 addwf isr_xC+1, f | |
| 251 movf PRODH, w | |
| 252 addwfc isr_xC+2, f ; Add to the Last Result | |
| 253 movf isr_xA+1, w ; Do the "O" Multiplication | |
| 254 mulwf isr_xB | |
| 255 movf PRODL, w ; Add the Lower Byte Next | |
| 256 addwf isr_xC+1, f | |
| 257 movf PRODH, w ; Add the High Byte First | |
| 258 addwfc isr_xC+2, f | |
| 259 btfsc STATUS, C ; Add the Carry | |
| 260 incf isr_xC+3, f | |
| 261 movf isr_xA+1, w ; Do the "F" Multiplication | |
| 262 mulwf isr_xB+1 | |
| 263 movf PRODL, w | |
| 264 addwf isr_xC+2, f | |
| 265 movf PRODH, w | |
| 266 addwfc isr_xC+3, f | |
| 267 return | |
|
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
268 |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
269 ;============================================================================= |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
270 ; 24bit shift, repeted WREG times. |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
271 ; Because we shift less than 8bits, and keep only C[2:1], we don't care what |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
272 ; bit is inserted... |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
273 ; |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
274 isr_shift_C31: |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
275 rrcf isr_xC+3,F ; Shift the three bytes... |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
276 rrcf isr_xC+2,F |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
277 rrcf isr_xC+1,F |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
278 decfsz WREG |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
279 bra isr_shift_C31 |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
280 return |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
281 |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
282 ;============================================================================= |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
283 ; s16 * s16 --> 32bit multiply (xA * xB --> xC) |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
284 ; Signed multiplication. |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
285 ; Code from... the Pic18F documentation ;-) |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
286 isr_unsigned_mult16x16: |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
287 MOVF isr_xA+0, W ; Lowest is simply a[0] * b[0] |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
288 MULWF isr_xB+0 |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
289 MOVFF PRODL, isr_xC+0 |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
290 MOVFF PRODH, isr_xC+1 |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
291 ; |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
292 MOVF isr_xA+1, W ; And highest a[1] * b[1] |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
293 MULWF isr_xB+1 |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
294 MOVFF PRODL, isr_xC+2 |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
295 MOVFF PRODH, isr_xC+3 |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
296 ; |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
297 MOVF isr_xA+0, W ; Intermediates do propagate: |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
298 MULWF isr_xB+1 |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
299 MOVF PRODL, W |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
300 ADDWF isr_xC+1, F ; Add cross products |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
301 MOVF PRODH, W |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
302 ADDWFC isr_xC+2, F ; with propagated carry |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
303 CLRF WREG |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
304 ADDWFC isr_xC+3, F ; on the three bytes. |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
305 ; |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
306 MOVF isr_xA+1, W ; And the second one, similarly. |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
307 MULWF isr_xB+0 |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
308 MOVF PRODL, W |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
309 ADDWF isr_xC+1, F ; Add cross products |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
310 MOVF PRODH, W |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
311 ADDWFC isr_xC+2, F |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
312 CLRF WREG |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
313 ADDWFC isr_xC+3, F |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
314 return |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
315 |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
316 isr_signed_mult16x16: |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
317 rcall isr_unsigned_mult16x16 |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
318 |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
319 ; Manage sign extension of operand B |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
320 BTFSS isr_xB+1,7 ; Is B negatif ? |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
321 BRA isr_signed_mult_checkA ; No: check ARG1 |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
322 MOVF isr_xA+0, W ; Yes: add -65536 * A |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
323 SUBWF isr_xC+2, F |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
324 MOVF isr_xA+1, W |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
325 SUBWFB isr_xC+3, F |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
326 ; And of operand A |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
327 isr_signed_mult_checkA |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
328 BTFSS isr_xA+1, 7 ; Is A negatif ? |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
329 RETURN ; No: done |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
330 MOVF isr_xB+0, W |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
331 SUBWF isr_xC+2, F |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
332 MOVF isr_xB+1, W |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
333 SUBWFB isr_xC+3, F |
|
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
105
diff
changeset
|
334 RETURN |
