changeset 343:d5240792be51

BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
author JeanDo
date Sat, 21 May 2011 14:38:56 +0200
parents 06299199dfb9
children 797e2ac42d24
files code_part1/OSTC_code_asm_part1/isr.asm
diffstat 1 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/isr.asm	Fri May 20 01:34:59 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/isr.asm	Sat May 21 14:38:56 2011 +0200
@@ -33,15 +33,17 @@
 ; Because the ISR can happend at any time, the read should be redone if bytes
 ; changed inbetween.
 ;
-; NOTE: Destination might be in any bank, so be BANK SAFE on b
-
-SAFE_2BYTE_COPY MACRO  a, b
+; Trashes: WREG and TABLAT
+; NOTE: Destination might be in any bank, so be BANK SAFE.
+;
+SAFE_2BYTE_COPY MACRO  from, to
         local   retry
 retry:
-        movf    a+1,W                   ; High byte in W, (CURRENT BANK ONLY)
-        movff   WREG,b+1                ; and destination.
-        movff   a,b                     ; Copy low byte.
-        xorwf   a+1,W                   ; High byte changed ??? (CURRENT BANK ONLY)
+        movff   from+1,WREG             ; High byte in W.
+        movff   WREG,to+1               ; and destination.
+        movff   from+0,to+0             ; Copy low byte.
+        movff   from+1,TABLAT           ; another bank-safe read.
+        xorwf   TABLAT,W                ; High byte changed ?
         bnz     retry
         ENDM