Changeset 625 for Deliverables/D2.2/8051
- Timestamp:
- Mar 3, 2011, 12:57:35 PM (10 years ago)
- Location:
- Deliverables/D2.2/8051
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Deliverables/D2.2/8051/myocamlbuild_config.ml
r624 r625 1 let parser_lib = "/home/ ayache/Downloads/Bol/Deliverables/D2.2/8051/lib"1 let parser_lib = "/home/dpm/Projects/Cerco/Deliverables/D2.2/8051/lib" -
Deliverables/D2.2/8051/src/ASM/ASMInterpret.ml
r622 r625 954 954 (fun (pc,exit_addr,labels,costs) i -> 955 955 match i with 956 `Label s when s = p.ASM.pexit_label -> 957 pc, pc, StringTools.Map.add s pc labels, costs 958 | `Label s -> 959 pc, exit_addr, StringTools.Map.add s pc labels, costs 956 `Label s when s = p.ASM.pexit_label -> pc, pc, StringTools.Map.add s pc labels, costs 957 | `Label s -> pc, exit_addr, StringTools.Map.add s pc labels, costs 960 958 | `Cost s -> pc, exit_addr, labels, BitVectors.WordMap.add pc s costs 961 | `Mov (_,_) -> pc, exit_addr, labels, costs959 | `Mov (_,_) -> (snd (half_add pc (vect_of_int 1 `Sixteen))), exit_addr, labels, costs 962 960 | `Jmp _ 963 | `Call _ -> 964 (snd (half_add pc (BitVectors.vect_of_int 3 `Sixteen))), 965 exit_addr, labels, costs 961 | `Call _ -> (snd (half_add pc (BitVectors.vect_of_int 3 `Sixteen))), exit_addr, labels, costs 966 962 (*CSC: very stupid: always expand to worst opcode *) 967 963 | `WithLabel i -> … … 970 966 let i',pc',_ = fetch (load_code_memory (assembly1 fake_jump)) (vect_of_int 0 `Sixteen) in 971 967 assert (fake_jump = i'); 972 (snd (half_add pc pc'), exit_addr, labels, costs) 968 let pc' = snd (half_add pc' (vect_of_int 5 `Sixteen)) in 969 (snd (half_add pc pc'), exit_addr, labels, costs) 973 970 | #instruction as i -> 974 971 let i',pc',_ = fetch (load_code_memory (assembly1 i)) (vect_of_int 0 `Sixteen) in … … 985 982 | `Cost _ -> [] 986 983 | `WithLabel i -> 987 let translation = assert false (* 984 (* We need to expand a conditional jump to a label to a machine language 985 conditional jump. Suppose we have: 986 JC label 987 This should be expanded to: 988 JC 2 -- size of a short jump 989 SJMP 3 -- size of a long jump 990 LJMP offset -- offset = position of label in code 991 And, for ever label appearing after the location of the jump in code 992 memory, we must increment by 5, as we added two new instructions. *) 993 let offset, jmp_address, translated_jump = 988 994 match i with 989 `JC (`Label a) -> (* 990 let offset = vect_of_int 2 `Eight in 991 let address = StringTools.Map.find a labels in *) 992 assert false 993 | `JNC a -> 994 (* let offset = vect_of_int 2 `Eight in *) 995 assert false 996 | `JB (b, a) -> 997 (* let offset = vect_of_int 3 `Eight in *) 998 assert false 999 | `JNB (b, a) -> 1000 (* let offset = vect_of_int 3 `Eight in *) 1001 assert false 1002 | `JBC (b, a) -> 1003 (* let offset = vect_of_int 2 `Eight in *) 1004 assert false 1005 | `JZ a -> 1006 (* let offset = vect_of_int 2 `Eight in *) 1007 assert false 1008 | `JNZ a -> 1009 (* let offset = vect_of_int 2 `Eight in *) 1010 assert false 1011 | `CJNE (args, a) -> 1012 (* let offset = vect_of_int 3 `Eight in *) 1013 assert false 1014 | `DJNZ ((`DIRECT, `REL _), a) -> 1015 (* let offset = vect_of_int 3 `Eight in *) 1016 assert false 1017 | `DJNZ ((`REG _, `REL _), a) -> 1018 (* let offset = vect_of_int 2 `Eight in *) 1019 assert false *) 995 `JC (`Label a) -> 996 let address = StringTools.Map.find a labels in 997 let reconstructed = `JC (`REL (vect_of_int 2 `Eight)) in 998 5, address, reconstructed 999 | `JNC (`Label a) -> 1000 let address = StringTools.Map.find a labels in 1001 let reconstructed = `JC (`REL (vect_of_int 2 `Eight)) in 1002 5, address, reconstructed 1003 | `JB (b, `Label a) -> 1004 let address = StringTools.Map.find a labels in 1005 let reconstructed = `JC (`REL (vect_of_int 2 `Eight)) in 1006 5, address, reconstructed 1007 | `JNB (b, `Label a) -> 1008 let address = StringTools.Map.find a labels in 1009 let reconstructed = `JC (`REL (vect_of_int 2 `Eight)) in 1010 5, address, reconstructed 1011 | `JBC (b, `Label a) -> 1012 let address = StringTools.Map.find a labels in 1013 let reconstructed = `JC (`REL (vect_of_int 2 `Eight)) in 1014 5, address, reconstructed 1015 | `JZ (`Label a) -> 1016 let address = StringTools.Map.find a labels in 1017 let reconstructed = `JC (`REL (vect_of_int 2 `Eight)) in 1018 5, address, reconstructed 1019 | `JNZ (`Label a) -> 1020 let address = StringTools.Map.find a labels in 1021 let reconstructed = `JC (`REL (vect_of_int 2 `Eight)) in 1022 5, address, reconstructed 1023 | `CJNE (args, `Label a) -> 1024 let address = StringTools.Map.find a labels in 1025 let reconstructed = `JC (`REL (vect_of_int 2 `Eight)) in 1026 5, address, reconstructed 1027 | `DJNZ (args, `Label a) -> 1028 let address = StringTools.Map.find a labels in 1029 let reconstructed = `JC (`REL (vect_of_int 2 `Eight)) in 1030 5, address, reconstructed 1020 1031 in 1021 List.flatten (List.map assembly1 translation) 1032 let sjmp, jmp = `SJMP (`REL (vect_of_int 3 `Eight)), `LJMP (`ADDR16 jmp_address) in 1033 let translation = [ translated_jump; sjmp; jmp ] in 1034 List.flatten (List.map assembly1 translation) 1022 1035 | `Mov (`DPTR,s) -> 1023 1036 let addrr16 = StringTools.Map.find s datalabels in
Note: See TracChangeset
for help on using the changeset viewer.