[98] | 1 | open BitVectors;; |
---|
| 2 | open ASM;; |
---|
| 3 | |
---|
| 4 | let pp_instruction = |
---|
| 5 | function |
---|
| 6 | `Label l -> l ^ ":" |
---|
| 7 | | `Cost l -> l ^ ":" |
---|
[121] | 8 | | `Jmp j -> "Jump: " ^ j |
---|
| 9 | | `Call j -> "Call: " ^ j |
---|
[98] | 10 | | `ACALL (`ADDR11 w) -> |
---|
| 11 | "ACALL addr11 (" ^ string_of_vect w ^ ")" |
---|
| 12 | | `ADD (`A,`REG (r1,r2,r3)) -> |
---|
| 13 | "ADD `A `Rn (" ^ string_of_bit r1 ^ string_of_bit r2 ^ string_of_bit r3 ^ ")" |
---|
| 14 | | `ADD (`A, `DIRECT b1) -> |
---|
| 15 | "ADD `A direct (" ^ string_of_vect b1 ^ ")" |
---|
| 16 | | `ADD (`A, `INDIRECT i1) -> |
---|
| 17 | "ADD `A @Ri (" ^ string_of_bit i1 ^ ")" |
---|
| 18 | | `ADD (`A, `DATA b1) -> |
---|
| 19 | "ADD `A #data (" ^ string_of_vect b1 ^ ")" |
---|
| 20 | | `ADDC (`A, `REG(r1,r2,r3)) -> |
---|
| 21 | "ADDC `A `Rn (" ^ string_of_bit r1 ^ string_of_bit r2 ^ string_of_bit r3 ^ ")" |
---|
| 22 | | `ADDC (`A, `DIRECT b1) -> |
---|
| 23 | "ADDC `A direct (" ^ string_of_vect b1 ^ ")" |
---|
| 24 | | `ADDC (`A,`INDIRECT i1) -> |
---|
| 25 | "ADDC `A @Ri (" ^ string_of_bit i1 ^ ")" |
---|
| 26 | | `ADDC (`A,`DATA b1) -> |
---|
| 27 | "ADDC `A #data (" ^ string_of_vect b1 ^ ")" |
---|
| 28 | | `AJMP (`ADDR11 w) -> |
---|
| 29 | "AJMP addr11 (" ^ string_of_vect w ^ ")" |
---|
| 30 | | `ANL (`U1 (`A, `REG (r1,r2,r3))) -> |
---|
| 31 | "ANL `A `Rn (" ^ string_of_bit r1 ^ string_of_bit r2 ^ string_of_bit r3 ^ ")" |
---|
| 32 | | `ANL (`U1 (`A, `DIRECT b1)) -> |
---|
| 33 | "ANL `A direct (" ^ string_of_vect b1 ^ ")" |
---|
| 34 | | `ANL (`U1 (`A, `INDIRECT i1)) -> |
---|
| 35 | "ANL `A @Ri (" ^ string_of_bit i1 ^ ")" |
---|
| 36 | | `ANL (`U1 (`A, `DATA b1)) -> |
---|
| 37 | "ANL `A #data (" ^ string_of_vect b1 ^ ")" |
---|
| 38 | | `ANL (`U2 (`DIRECT b1,`A)) -> |
---|
| 39 | "ANL direct `A (" ^ string_of_vect b1 ^ ")" |
---|
| 40 | | `ANL (`U2 (`DIRECT b1,`DATA b2)) -> |
---|
| 41 | "ANL direct #data (" ^ string_of_vect b1 ^ string_of_vect b2 ^ ")" |
---|
| 42 | | `ANL (`U3 (`C,`BIT b1)) -> |
---|
| 43 | "ANL `C bit (" ^ string_of_vect b1 ^ ")" |
---|
| 44 | | `ANL (`U3 (`C,`NBIT b1)) -> |
---|
| 45 | "ANL `C /bit (" ^ string_of_vect b1 ^ ")" |
---|
| 46 | | `CJNE (`U1 (`A, `DIRECT b1), `REL b2) -> |
---|
| 47 | "CJNE `A direct rel (" ^ string_of_vect b1 ^ string_of_vect b2 ^ ")" |
---|
| 48 | | `CJNE (`U1 (`A, `DATA b1), `REL b2) -> |
---|
| 49 | "CJNE `A #data rel (" ^ string_of_vect b1 ^ string_of_vect b2 ^ ")" |
---|
| 50 | | `CJNE (`U2 (`REG(r1,r2,r3), `DATA b1), `REL b2) -> |
---|
| 51 | "CJNE `Rn #data rel (" ^ string_of_bit r1 ^ string_of_bit r2 ^ string_of_bit r3 ^ string_of_vect b1 ^ string_of_vect b2 ^ ")" |
---|
| 52 | | `CJNE (`U2 (`INDIRECT i1, `DATA b1), `REL b2) -> |
---|
| 53 | "CJNE @Ri #data rel (" ^ string_of_bit i1 ^ string_of_vect b1 ^ string_of_vect b2 ^ ")" |
---|
| 54 | | `CLR `A -> "CLR `A" |
---|
| 55 | | `CLR `C -> "CLR `C" |
---|
| 56 | | `CLR (`BIT b1) -> "CLR bit (" ^ string_of_vect b1 ^ ")" |
---|
| 57 | | `CPL `A -> "CPL A" |
---|
| 58 | | `CPL `C -> "CPL C" |
---|
[121] | 59 | | `CPL (`BIT b1) -> "CPL bit (" ^ string_of_vect b1 ^ ")" |
---|
[98] | 60 | | `DA `A -> |
---|
| 61 | "DA `A" |
---|
| 62 | | `DEC `A -> |
---|
| 63 | "DEC `A" |
---|
| 64 | | `DEC (`REG(r1,r2,r3)) -> |
---|
| 65 | "DEC `Rn (" ^ string_of_bit r1 ^ string_of_bit r2 ^ string_of_bit r3 ^ ")" |
---|
| 66 | | `DEC (`DIRECT b1) -> |
---|
| 67 | "DEC direct (" ^ string_of_vect b1 ^ ")" |
---|
| 68 | | `DEC (`INDIRECT i1) -> |
---|
| 69 | "DEC @Ri (" ^ string_of_bit i1 ^ ")" |
---|
| 70 | | `DIV (`A, `B) -> |
---|
| 71 | "DIV `A `B" |
---|
| 72 | | `DJNZ (`REG(r1,r2,r3), `REL b1) -> |
---|
| 73 | "DJNZ `Rn rel (" ^ string_of_bit r1 ^ string_of_bit r2 ^ string_of_bit r3 ^ string_of_vect b1 ^ ")" |
---|
| 74 | | `DJNZ (`DIRECT b1, `REL b2) -> |
---|
| 75 | "DJNZ direct rel (" ^ string_of_vect b1 ^ string_of_vect b2 ^ ")" |
---|
| 76 | | `INC `A -> |
---|
| 77 | "INC `A" |
---|
| 78 | | `INC (`REG(r1,r2,r3)) -> |
---|
| 79 | "INC `Rn (" ^ string_of_bit r1 ^ string_of_bit r2 ^ string_of_bit r3 ^ ")" |
---|
| 80 | | `INC (`DIRECT b1) -> |
---|
| 81 | "INC direct (" ^ string_of_vect b1 ^ ")" |
---|
| 82 | | `INC (`INDIRECT i1) -> |
---|
| 83 | "INC @Ri (" ^ string_of_bit i1 ^ ")" |
---|
| 84 | | `INC `DPTR -> |
---|
| 85 | "INC `DPTR" |
---|
| 86 | | `JB (`BIT b1, `REL b2) -> |
---|
| 87 | "JB bit rel (" ^ string_of_vect b1 ^ string_of_vect b2 ^ ")" |
---|
| 88 | | `JBC (`BIT b1, `REL b2) -> |
---|
| 89 | "JBC bit rel (" ^ string_of_vect b1 ^ string_of_vect b2 ^ ")" |
---|
| 90 | | `JC (`REL b1) -> |
---|
| 91 | "JC rel (" ^ string_of_vect b1 ^ ")" |
---|
| 92 | | `JMP `IND_DPTR -> |
---|
| 93 | "JMP @A + `DPTR" |
---|
| 94 | | `JNB (`BIT b1, `REL b2) -> |
---|
| 95 | "JNB bit rel (" ^ string_of_vect b1 ^ string_of_vect b2 ^ ")" |
---|
| 96 | | `JNC (`REL b1) -> |
---|
| 97 | "JNC rel (" ^ string_of_vect b1 ^ ")" |
---|
| 98 | | `JNZ (`REL b1) -> |
---|
| 99 | "JNZ rel (" ^ string_of_vect b1 ^ ")" |
---|
| 100 | | `JZ (`REL b1) -> |
---|
| 101 | "JZ rel (" ^ string_of_vect b1 ^ ")" |
---|
| 102 | | `LCALL (`ADDR16 w) -> |
---|
| 103 | "LCALL addr16 (" ^ string_of_vect w ^ ")" |
---|
| 104 | | `LJMP (`ADDR16 w) -> |
---|
| 105 | "LJMP addr16 (" ^ string_of_vect w ^ ")" |
---|
| 106 | | `MOV (`U1 (`A, `REG(r1,r2,r3))) -> |
---|
| 107 | "MOV `A `Rn (" ^ string_of_bit r1 ^ string_of_bit r2 ^ string_of_bit r3 ^ ")" |
---|
| 108 | | `MOV (`U1 (`A, `DIRECT b1)) -> |
---|
| 109 | "MOV `A direct (" ^ string_of_vect b1 ^ ")" |
---|
| 110 | | `MOV (`U1 (`A, `INDIRECT i1)) -> |
---|
| 111 | "MOV `A @Ri (" ^ string_of_bit i1 ^ ")" |
---|
| 112 | | `MOV (`U1 (`A, `DATA b1)) -> |
---|
| 113 | "MOV `A #data (" ^ string_of_vect b1 ^ ")" |
---|
| 114 | | `MOV (`U2 (`REG(r1,r2,r3), `A)) -> |
---|
| 115 | "MOV `Rn `A (" ^ string_of_bit r1 ^ string_of_bit r2 ^ string_of_bit r3 ^ ")" |
---|
| 116 | | `MOV (`U2 (`REG(r1,r2,r3), (`DIRECT b1))) -> |
---|
| 117 | "MOV `Rn direct (" ^ string_of_bit r1 ^ string_of_bit r2 ^ string_of_bit r3 ^ ")" |
---|
| 118 | | `MOV (`U2 (`REG(r1,r2,r3), (`DATA b1))) -> |
---|
| 119 | "MOV `Rn #data (" ^ string_of_bit r1 ^ string_of_bit r2 ^ string_of_bit r3 ^ ")" |
---|
| 120 | | `MOV (`U3 (`DIRECT b1, `A)) -> |
---|
| 121 | "MOV direct `A (" ^ string_of_vect b1 ^ ")" |
---|
| 122 | | `MOV (`U3 (`DIRECT b1, `REG(r1,r2,r3))) -> |
---|
| 123 | "MOV direct `Rn (" ^ string_of_bit r1 ^ string_of_bit r2 ^ string_of_bit r3 ^ ")" |
---|
| 124 | | `MOV (`U3 (`DIRECT b1, `DIRECT b2)) -> |
---|
| 125 | "MOV direct direct (" ^ string_of_vect b1 ^ string_of_vect b2 ^ ")" |
---|
| 126 | | `MOV (`U3 (`DIRECT b1, `INDIRECT i1)) -> |
---|
| 127 | "MOV direct @Ri (" ^ string_of_vect b1 ^ string_of_bit i1 ^ ")" |
---|
| 128 | | `MOV (`U3 (`DIRECT b1, `DATA b2)) -> |
---|
| 129 | "MOV direct #data (" ^ string_of_vect b1 ^ string_of_vect b2 ^ ")" |
---|
| 130 | | `MOV (`U2 (`INDIRECT i1, `A)) -> |
---|
| 131 | "MOV @Ri `A (" ^ string_of_bit i1 ^ ")" |
---|
| 132 | | `MOV (`U2 (`INDIRECT i1, `DIRECT b1)) -> |
---|
| 133 | "MOV @Ri direct (" ^ string_of_bit i1 ^ string_of_vect b1 ^ ")" |
---|
| 134 | | `MOV (`U2 (`INDIRECT i1, `DATA b1)) -> |
---|
| 135 | "MOV @Ri #data (" ^ string_of_bit i1 ^ string_of_vect b1 ^ ")" |
---|
| 136 | | `MOV (`U5 (`C, `BIT b1)) -> |
---|
| 137 | "MOV `C bit (" ^ string_of_vect b1 ^ ")" |
---|
| 138 | | `MOV (`U6 (`BIT b1, `C)) -> |
---|
| 139 | "MOV bit `C (" ^ string_of_vect b1 ^ ")" |
---|
| 140 | | `MOV (`U4 (`DPTR, `DATA16 w)) -> |
---|
| 141 | "MOV `DPTR #data16 (" ^ string_of_vect w ^ ")" |
---|
| 142 | | `MOVC (`A, `A_DPTR) -> |
---|
| 143 | "MOVC `A @A + `DPTR" |
---|
| 144 | | `MOVC (`A, `A_PC) -> |
---|
| 145 | "MOVC `A @A + `PC" |
---|
| 146 | | `MOVX (`U1 (`A, `EXT_INDIRECT i1)) -> |
---|
| 147 | "MOVX `A @Ri (" ^ string_of_bit i1 ^ ")" |
---|
| 148 | | `MOVX (`U1 (`A, `EXT_IND_DPTR)) -> |
---|
| 149 | "MOVX `A @DPTR" |
---|
| 150 | | `MOVX (`U2 (`EXT_INDIRECT i1, `A)) -> |
---|
| 151 | "MOVX @Ri `A ( " ^ string_of_bit i1 ^ ")" |
---|
| 152 | | `MOVX (`U2 (`EXT_IND_DPTR, `A)) -> |
---|
| 153 | "MOVX @DPTR `A" |
---|
| 154 | | `MUL(`A, `B) -> |
---|
| 155 | "MUL `A `B" |
---|
| 156 | | `NOP -> |
---|
| 157 | "NOP" |
---|
| 158 | | `ORL (`U1(`A, `REG(r1,r2,r3))) -> |
---|
| 159 | "ORL `A `Rn (" ^ string_of_bit r1 ^ string_of_bit r2 ^ string_of_bit r3 ^ ")" |
---|
| 160 | | `ORL (`U1(`A, `DIRECT b1)) -> |
---|
| 161 | "ORL `A direct (" ^ string_of_vect b1 ^ ")" |
---|
| 162 | | `ORL (`U1(`A, `INDIRECT i1)) -> |
---|
| 163 | "ORL `A @Ri (" ^ string_of_bit i1 ^ ")" |
---|
| 164 | | `ORL (`U1(`A, `DATA b1)) -> |
---|
| 165 | "ORL `A #data (" ^ string_of_vect b1 ^ ")" |
---|
| 166 | | `ORL (`U2(`DIRECT b1, `A)) -> |
---|
| 167 | "ORL direct `A (" ^ string_of_vect b1 ^ ")" |
---|
| 168 | | `ORL (`U2 (`DIRECT b1, `DATA b2)) -> |
---|
| 169 | "ORL direct #data (" ^ string_of_vect b1 ^ string_of_vect b2 ^ ")" |
---|
| 170 | | `ORL (`U3 (`C, `BIT b1)) -> |
---|
| 171 | "ORL `C bit (" ^ string_of_vect b1 ^ ")" |
---|
| 172 | | `ORL (`U3 (`C, `NBIT b1)) -> |
---|
| 173 | "ORL `C \\bit (" ^ string_of_vect b1 ^ ")" |
---|
| 174 | | `POP (`DIRECT b1) -> |
---|
| 175 | "POP direct (" ^ string_of_vect b1 ^ ")" |
---|
| 176 | | `PUSH (`DIRECT b1) -> |
---|
| 177 | "PUSH direct (" ^ string_of_vect b1 ^ ")" |
---|
| 178 | | `RET -> |
---|
| 179 | "RET" |
---|
| 180 | | `RETI -> |
---|
| 181 | "RETI" |
---|
| 182 | | `RL `A -> |
---|
| 183 | "RL `A" |
---|
| 184 | | `RLC `A -> |
---|
| 185 | "RLC `A" |
---|
| 186 | | `RR `A -> |
---|
| 187 | "RR `A" |
---|
| 188 | | `RRC `A -> |
---|
| 189 | "RRC `A" |
---|
| 190 | | `SETB `C -> |
---|
| 191 | "SETB `C" |
---|
| 192 | | `SETB (`BIT b1) -> |
---|
| 193 | "SETB bit (" ^ string_of_vect b1 ^ ")" |
---|
| 194 | | `SJMP (`REL b1) -> |
---|
| 195 | "SJMP rel (" ^ string_of_vect b1 ^ ")" |
---|
| 196 | | `SUBB (`A, `REG(r1,r2,r3)) -> |
---|
| 197 | "SUBB `A `Rn (" ^ string_of_bit r1 ^ string_of_bit r2 ^ string_of_bit r3 ^ ")" |
---|
| 198 | | `SUBB (`A, `DIRECT b1) -> |
---|
| 199 | "SUBB `A direct (" ^ string_of_vect b1 ^ ")" |
---|
| 200 | | `SUBB (`A, `INDIRECT i1) -> |
---|
| 201 | "SUBB `A @Ri (" ^ string_of_bit i1 ^ ")" |
---|
| 202 | | `SUBB (`A, `DATA b1) -> |
---|
| 203 | "SUBB `A #data (" ^ string_of_vect b1 ^ ")" |
---|
| 204 | | `SWAP `A -> |
---|
| 205 | "SWAP `A" |
---|
| 206 | | `XCH (`A, `REG(r1,r2,r3)) -> |
---|
| 207 | "XCH `A `Rn (" ^ string_of_bit r1 ^ string_of_bit r2 ^ string_of_bit r3 ^ ")" |
---|
| 208 | | `XCH (`A, `DIRECT b1) -> |
---|
| 209 | "XCH `A direct (" ^ string_of_vect b1 ^ ")" |
---|
| 210 | | `XCH (`A, `INDIRECT i1) -> |
---|
| 211 | "XCH `A @Ri (" ^ string_of_bit i1 ^ ")" |
---|
| 212 | | `XCHD(`A, `INDIRECT i1) -> |
---|
| 213 | "XCHD `A @Ri (" ^ string_of_bit i1 ^ ")" |
---|
| 214 | | `XRL(`U1(`A, `REG(r1,r2,r3))) -> |
---|
| 215 | "XRL `A `Rn (" ^ string_of_bit r1 ^ string_of_bit r2 ^ string_of_bit r3 ^ ")" |
---|
| 216 | | `XRL(`U1(`A, `DIRECT b1)) -> |
---|
| 217 | "XRL `A direct (" ^ string_of_vect b1 ^ ")" |
---|
| 218 | | `XRL(`U1(`A, `INDIRECT i1)) -> |
---|
| 219 | "XRL `A @Ri (" ^ string_of_bit i1 ^ ")" |
---|
| 220 | | `XRL(`U1(`A, `DATA b1)) -> |
---|
| 221 | "XRL `A #data (" ^ string_of_vect b1 ^ ")" |
---|
| 222 | | `XRL(`U2(`DIRECT b1, `A)) -> |
---|
| 223 | "XRL direct `A (" ^ string_of_vect b1 ^ ")" |
---|
| 224 | | `XRL(`U2(`DIRECT b1, `DATA b2)) -> |
---|
| 225 | "XRL direct #data (" ^ string_of_vect b2 ^ ")" |
---|
[121] | 226 | | _ -> "BUG: Unimplemented!" |
---|