]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/matita/contribs/ng_assembly/emulator/read_write/fetch.ma
(no commit message)
[helm.git] / helm / software / matita / contribs / ng_assembly / emulator / read_write / fetch.ma
index 37d0951065cecaaac8945d03d3dfd05f27cc5ca5..1d51f2bcfe393af529ac85a6b97a56146948f18f 100755 (executable)
@@ -31,23 +31,23 @@ ninductive error_type : Type ≝
 .
 
 (* - errore: interessa solo l'errore
-   - ok: interessa info e il nuovo pc *)
+   - ok: interessa info, vecchio pc, nuovo pc *)
 ninductive fetch_result (A:Type) : Type ≝
   FetchERR : error_type → fetch_result A
-| FetchOK  : A → word16 → fetch_result A.
+| FetchOK  : A → word16 → word16 → fetch_result A.
 
 ndefinition fetch_byte_aux ≝
-λm:mcu_type.λpc:word16.λbh:byte8.
+λm:mcu_type.λpco,pcn:word16.λbh:byte8.
  match full_info_of_word16 m (Byte bh) with
   [ None ⇒ FetchERR ? ILL_FETCH_AD
-  | Some info ⇒ FetchOK ? info pc
+  | Some info ⇒ FetchOK ? info pco pcn
   ].
 
 ndefinition fetch_word_aux ≝
-λm:mcu_type.λpc:word16.λw:word16.
+λm:mcu_type.λpco,pcn:word16.λw:word16.
  match full_info_of_word16 m (Word w) with
   [ None ⇒ FetchERR ? ILL_FETCH_AD
-  | Some info ⇒ FetchOK ? info pc
+  | Some info ⇒ FetchOK ? info pco pcn
   ].
 
 (* opcode a byte : HC05 / RS08 *)
@@ -55,7 +55,7 @@ ndefinition fetch_byte ≝
 λm:mcu_type.λfR:word32 → option byte8.λpc:word16.
  match fR (extu_w32 pc) with
   [ None ⇒ FetchERR ? ILL_FETCH_AD
-  | Some bh ⇒ fetch_byte_aux m (succ_w16 pc) bh ].
+  | Some bh ⇒ fetch_byte_aux m pc (succ_w16 pc) bh ].
 
 (* opcode a byte o 0x9E + byte : HC08 / HCS08 *)
 ndefinition Freescale_fetch_byte_or_word ≝
@@ -65,9 +65,9 @@ ndefinition Freescale_fetch_byte_or_word ≝
   | Some bh ⇒ match eq_b8 bh 〈x9,xE〉 with
    [ true ⇒ match fR (extu_w32 (succ_w16 pc)) with
     [ None ⇒ FetchERR ? ILL_FETCH_AD
-    | Some bl ⇒ fetch_word_aux m (succ_w16 (succ_w16 pc)) 〈bh:bl〉
+    | Some bl ⇒ fetch_word_aux m pc (succ_w16 (succ_w16 pc)) 〈bh:bl〉
     ]
-   | false ⇒ fetch_byte_aux m (succ_w16 pc) bh
+   | false ⇒ fetch_byte_aux m pc (succ_w16 pc) bh
    ]
   ].
 
@@ -76,15 +76,14 @@ ndefinition Freescale_fetch_byte_or_word ≝
 (* pc word aligned, mappato in 0x02000000-0x0201FFFF *)
 ndefinition IP2022_fetch_byte_or_word ≝
 λm:mcu_type.λfR:word32 → option byte8.λpc:word16.
- let map_pc ≝ rol_w32 〈〈〈x0,x1〉:〈x0,x0〉〉.pc〉 in
- match fR map_pc with
+ match fR (rol_w32 〈〈〈x0,x1〉:〈x0,x0〉〉.pc〉) with
   [ None ⇒ FetchERR ? ILL_FETCH_AD
   | Some bh ⇒ match eq_b8 bh 〈x0,x0〉 with
-   [ true ⇒ match fR (succ_w32 map_pc) with
+   [ true ⇒ match fR (rol_w32 〈〈〈x8,x1〉:〈x0,x0〉〉.pc〉) with
     [ None ⇒ FetchERR ? ILL_FETCH_AD
-    | Some bl ⇒ fetch_word_aux m (succ_w16 pc) 〈bh:bl〉
+    | Some bl ⇒ fetch_word_aux m pc (succ_w16 pc) 〈bh:bl〉
     ]
-   | false ⇒ fetch_byte_aux m (succ_w16 pc) bh
+   | false ⇒ fetch_byte_aux m pc (succ_w16 pc) bh
    ]
   ].