Last change
on this file since 2745 was
2705,
checked in by sacerdot, 8 years ago
|
More progress in ASM towards implementing the new pseudoinstructions.
|
File size:
2.0 KB
|
Rev | Line | |
---|
[1939] | 1 | include "ASM/ASM.ma". |
---|
| 2 | include "ASM/Status.ma". |
---|
| 3 | include "ASM/Fetch.ma". |
---|
[1944] | 4 | include "common/StructuredTraces.ma". |
---|
[1939] | 5 | |
---|
| 6 | include "basics/lists/listb.ma". |
---|
| 7 | |
---|
| 8 | definition ASM_classify00: ∀a. preinstruction a → status_class ≝ |
---|
| 9 | λa, pre. |
---|
| 10 | match pre with |
---|
| 11 | [ RET ⇒ cl_return |
---|
| 12 | | RETI ⇒ cl_return |
---|
| 13 | | JZ _ ⇒ cl_jump |
---|
| 14 | | JNZ _ ⇒ cl_jump |
---|
| 15 | | JC _ ⇒ cl_jump |
---|
| 16 | | JNC _ ⇒ cl_jump |
---|
| 17 | | JB _ _ ⇒ cl_jump |
---|
| 18 | | JNB _ _ ⇒ cl_jump |
---|
| 19 | | JBC _ _ ⇒ cl_jump |
---|
| 20 | | CJNE _ _ ⇒ cl_jump |
---|
| 21 | | DJNZ _ _ ⇒ cl_jump |
---|
[2705] | 22 | | JMP _ ⇒ cl_call |
---|
[1939] | 23 | | _ ⇒ cl_other |
---|
| 24 | ]. |
---|
| 25 | |
---|
| 26 | definition ASM_classify0: instruction → status_class ≝ |
---|
| 27 | λi. |
---|
| 28 | match i with |
---|
| 29 | [ RealInstruction pre ⇒ ASM_classify00 [[relative]] pre |
---|
| 30 | | ACALL _ ⇒ cl_call |
---|
| 31 | | LCALL _ ⇒ cl_call |
---|
| 32 | | AJMP _ ⇒ cl_other |
---|
| 33 | | LJMP _ ⇒ cl_other |
---|
| 34 | | SJMP _ ⇒ cl_other |
---|
| 35 | | _ ⇒ cl_other |
---|
| 36 | ]. |
---|
| 37 | |
---|
| 38 | definition current_instruction0 ≝ |
---|
| 39 | λcode_memory: BitVectorTrie Byte 16. |
---|
| 40 | λprogram_counter: Word. |
---|
| 41 | \fst (\fst (fetch … code_memory program_counter)). |
---|
| 42 | |
---|
| 43 | definition current_instruction ≝ |
---|
| 44 | λcode_memory. |
---|
| 45 | λs: Status code_memory. |
---|
| 46 | current_instruction0 code_memory (program_counter … s). |
---|
| 47 | |
---|
| 48 | definition current_instruction_label ≝ |
---|
| 49 | λcode_memory. |
---|
[2516] | 50 | λcost_labels: BitVectorTrie costlabel 16. |
---|
[1939] | 51 | λs: Status code_memory. |
---|
| 52 | let pc ≝ program_counter … code_memory s in |
---|
| 53 | lookup_opt … pc cost_labels. |
---|
| 54 | |
---|
| 55 | definition next_instruction_properly_relates_program_counters ≝ |
---|
| 56 | λcode_memory. |
---|
| 57 | λbefore: Status code_memory. |
---|
| 58 | λafter : Status code_memory. |
---|
| 59 | let program_counter_before ≝ program_counter ? code_memory before in |
---|
| 60 | let 〈instruction, program_counter_after, ticks〉 ≝ fetch code_memory program_counter_before in |
---|
| 61 | program_counter ? code_memory after = program_counter_after. |
---|
| 62 | |
---|
| 63 | definition word_deqset: DeqSet ≝ |
---|
| 64 | mk_DeqSet Word (eq_bv 16) ?. |
---|
| 65 | @refl_iff_eq_bv_true |
---|
| 66 | qed. |
---|
| 67 | |
---|
| 68 | definition ASM_classify: ∀code_memory. Status code_memory → status_class ≝ |
---|
| 69 | λcode_memory. |
---|
| 70 | λs: Status code_memory. |
---|
| 71 | ASM_classify0 (current_instruction … s). |
---|
Note: See
TracBrowser
for help on using the repository browser.