Changeset 97


Ignore:
Timestamp:
Sep 21, 2010, 1:51:59 PM (9 years ago)
Author:
mulligan
Message:

Move to polymorphic variants everywhere (scary...)

Location:
Deliverables/D4.1
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D4.1/ASM.mli

    r92 r97  
    2828type instruction =
    2929 (* arithmetic operations *)
    30    ADD of acc * [ reg | direct | indirect | data ]
    31  | ADDC of acc * [ reg | direct | indirect | data ]
    32  | SUBB of acc * [ reg | direct | indirect | data ]
    33  | INC of [ acc | reg | direct | indirect | dptr ]
    34  | DEC of [ acc | reg | direct | indirect ]
    35  | MUL of acc * b
    36  | DIV of acc * b
    37  | DA  of acc
     30 [ `ADD of acc * [ reg | direct | indirect | data ]
     31 | `ADDC of acc * [ reg | direct | indirect | data ]
     32 | `SUBB of acc * [ reg | direct | indirect | data ]
     33 | `INC of [ acc | reg | direct | indirect | dptr ]
     34 | `DEC of [ acc | reg | direct | indirect ]
     35 | `MUL of acc * b
     36 | `DIV of acc * b
     37 | `DA  of acc
    3838
    3939 (* logical operations *)
    40  | ANL of
     40 | `ANL of
    4141    (acc * [ reg | direct | indirect | data ],
    4242     direct * [ acc | data ],
    4343     carry * [ bit | nbit]) union3
    44  | ORL of
     44 | `ORL of
    4545    (acc * [ reg | data | direct | indirect ],
    4646     direct * [ acc | data ],
    4747     carry * [ bit | nbit]) union3
    48  | XRL of
     48 | `XRL of
    4949    (acc * [ data | reg | direct | indirect ],
    5050     direct * [ acc | data ]) union2
    51  | CLR of [ acc | carry | bit ]
    52  | CPL of [ acc | carry | bit ]
    53  | RL of acc
    54  | RLC of acc
    55  | RR of acc
    56  | RRC of acc
    57  | SWAP of acc
     51 | `CLR of [ acc | carry | bit ]
     52 | `CPL of [ acc | carry | bit ]
     53 | `RL of acc
     54 | `RLC of acc
     55 | `RR of acc
     56 | `RRC of acc
     57 | `SWAP of acc
    5858
    5959 (* data transfer *)
    60  | MOV of
     60 | `MOV of
    6161    (acc * [ reg | direct | indirect | data ],
    6262     [ reg | indirect ] * [ acc | direct | data ],
     
    6666     bit * carry
    6767     ) union6
    68  | MOVC of acc * [ acc_dptr | acc_pc ]
    69  | MOVX of (acc * [ ext_indirect | ext_indirect_dptr ],
     68 | `MOVC of acc * [ acc_dptr | acc_pc ]
     69 | `MOVX of (acc * [ ext_indirect | ext_indirect_dptr ],
    7070            [ ext_indirect | ext_indirect_dptr ] * acc) union2
    71  | SETB of [ carry | bit ]
    72  | PUSH of direct
    73  | POP of direct
    74  | XCH of acc * [ reg | direct | indirect ]
    75  | XCHD of acc * indirect
     71 | `SETB of [ carry | bit ]
     72 | `PUSH of direct
     73 | `POP of direct
     74 | `XCH of acc * [ reg | direct | indirect ]
     75 | `XCHD of acc * indirect
    7676
    7777 (* program branching *)
    78  | JC of rel
    79  | JNC of rel
    80  | JB of bit * rel
    81  | JNB of bit * rel
    82  | JBC of bit * rel
    83  | ACALL of addr11
    84  | LCALL of addr16
    85  | RET
    86  | RETI
    87  | AJMP of addr11
    88  | LJMP of addr16
    89  | SJMP of rel
    90  | JMP of indirect_dptr
    91  | JZ of rel
    92  | JNZ of rel
    93  | CJNE of (acc * [ direct | data ], [ reg | indirect ] * data) union2 * rel
    94  | DJNZ of [ reg | direct ] * rel
    95  | NOP
     78 | `JC of rel
     79 | `JNC of rel
     80 | `JB of bit * rel
     81 | `JNB of bit * rel
     82 | `JBC of bit * rel
     83 | `ACALL of addr11
     84 | `LCALL of addr16
     85 | `RET
     86 | `RETI
     87 | `AJMP of addr11
     88 | `LJMP of addr16
     89 | `SJMP of rel
     90 | `JMP of indirect_dptr
     91 | `JZ of rel
     92 | `JNZ of rel
     93 | `CJNE of (acc * [ direct | data ], [ reg | indirect ] * data) union2 * rel
     94 | `DJNZ of [ reg | direct ] * rel
     95 | `NOP ]
     96
     97type labelled_instruction =
     98 [ instruction
     99 | `Label of string
     100 | `Cost of string ]
  • Deliverables/D4.1/ASMInterpret.ml

    r95 r97  
    8484
    8585let get_cy_flag status =
    86   let [cy;_;_;_;_;_;_;_] = to_bits status.psw in cy
     86  let (cy,_,_,_),(_,_,_,_) = bits_of_byte status.psw in cy
    8787let get_ac_flag status =
    88   let [_;ac;_;_;_;_;_;_] = to_bits status.psw in ac
     88  let (_,ac,_,_),(_,_,_,_) = bits_of_byte status.psw in ac
    8989let get_fo_flag status =
    90   let [_;_;fo;_;_;_;_;_] = to_bits status.psw in fo
     90  let (_,_,fo,_),(_,_,_,_) = bits_of_byte status.psw in fo
    9191let get_rs1_flag status =
    92   let [_;_;_;rs1;_;_;_;_] = to_bits status.psw in rs1
     92  let (_,_,_,rs1),(_,_,_,_) = bits_of_byte status.psw in rs1
    9393let get_rs0_flag status =
    94   let [_;_;_;_;rs0;_;_;_] = to_bits status.psw in rs0
     94  let (_,_,_,_),(rs0,_,_,_) = bits_of_byte status.psw in rs0
    9595let get_ov_flag status =
    96   let [_;_;_;_;_;ov;_;_] = to_bits status.psw in ov
     96  let (_,_,_,_),(_,ov,_,_) = bits_of_byte status.psw in ov
    9797let get_ud_flag status =
    98   let [_;_;_;_;_;_;ud;_] = to_bits status.psw in ud
     98  let (_,_,_,_),(_,_,ud,_) = bits_of_byte status.psw in ud
    9999let get_p_flag status =
    100   let [_;_;_;_;_;_;_;p] = to_bits status.psw in p
     100  let (_,_,_,_),(_,_,_,p) = bits_of_byte status.psw in p
    101101
    102102(* timings taken from SIEMENS *)
     
    115115     (a10,a9,a8,true),(false,false,false,true) ->
    116116      let pc,b1 = next pc in
    117        ACALL (`ADDR11 (mk_word11 a10 a9 a8 b1)), pc, 2
     117       `ACALL (`ADDR11 (mk_word11 a10 a9 a8 b1)), pc, 2
    118118   | (false,false,true,false),(true,r1,r2,r3) ->
    119       ADD (`A,`REG (r1,r2,r3)), pc, 1
     119      `ADD (`A,`REG (r1,r2,r3)), pc, 1
    120120   | (false,false,true,false),(false,true,false,true) ->
    121121      let pc,b1 = next pc in
    122        ADD (`A,`DIRECT b1), pc, 1
     122       `ADD (`A,`DIRECT b1), pc, 1
    123123   | (false,false,true,false),(false,true,true,i1) ->
    124        ADD (`A,`INDIRECT i1), pc, 1
     124       `ADD (`A,`INDIRECT i1), pc, 1
    125125   | (false,false,true,false),(false,true,false,false) ->
    126126      let pc,b1 = next pc in
    127        ADD (`A,`DATA b1), pc, 1
     127       `ADD (`A,`DATA b1), pc, 1
    128128   | (false,false,true,true),(true,r1,r2,r3) ->
    129        ADDC (`A,`REG (r1,r2,r3)), pc, 1
     129       `ADDC (`A,`REG (r1,r2,r3)), pc, 1
    130130   | (false,false,true,true),(false,true,false,true) ->
    131131      let pc,b1 = next pc in
    132        ADDC (`A,`DIRECT b1), pc, 1
     132       `ADDC (`A,`DIRECT b1), pc, 1
    133133   | (false,false,true,true),(false,true,true,i1) ->
    134        ADDC (`A,`INDIRECT i1), pc, 1
     134       `ADDC (`A,`INDIRECT i1), pc, 1
    135135   | (false,false,true,true),(false,true,false,false) ->
    136136      let pc,b1 = next pc in
    137        ADDC (`A,`DATA b1), pc, 1
     137       `ADDC (`A,`DATA b1), pc, 1
    138138   | (a10,a9,a8,false),(false,false,false,true) ->
    139139      let pc,b1 = next pc in
    140        AJMP (`ADDR11 (mk_word11 a10 a9 a8 b1)), pc, 2
     140       `AJMP (`ADDR11 (mk_word11 a10 a9 a8 b1)), pc, 2
    141141   | (false,true,false,true),(true,r1,r2,r3) ->
    142       ANL (`U1 (`A, `REG (r1,r2,r3))), pc, 1
     142      `ANL (`U1 (`A, `REG (r1,r2,r3))), pc, 1
    143143   | (false,true,false,true),(false,true,false,true) ->
    144144      let pc,b1 = next pc in
    145        ANL (`U1 (`A, `DIRECT b1)), pc, 1
     145       `ANL (`U1 (`A, `DIRECT b1)), pc, 1
    146146   | (false,true,false,true),(false,true,true,i1) ->
    147        ANL (`U1 (`A, `INDIRECT i1)), pc, 1
     147       `ANL (`U1 (`A, `INDIRECT i1)), pc, 1
    148148   | (false,true,false,true),(false,true,false,false) ->
    149149      let pc,b1 = next pc in
    150        ANL (`U1 (`A, `DATA b1)), pc, 1
     150       `ANL (`U1 (`A, `DATA b1)), pc, 1
    151151   | (false,true,false,true),(false,false,true,false) ->
    152152      let pc,b1 = next pc in
    153        ANL (`U2 (`DIRECT b1,`A)), pc, 1
     153       `ANL (`U2 (`DIRECT b1,`A)), pc, 1
    154154   | (false,true,false,true),(false,false,true,true) ->
    155155      let pc,b1 = next pc in
    156156      let pc,b2 = next pc in
    157        ANL (`U2 (`DIRECT b1,`DATA b2)), pc, 2
     157       `ANL (`U2 (`DIRECT b1,`DATA b2)), pc, 2
    158158   | (true,false,false,false),(false,false,true,false) ->
    159159      let pc,b1 = next pc in
    160        ANL (`U3 (`C,`BIT b1)), pc, 2
     160       `ANL (`U3 (`C,`BIT b1)), pc, 2
    161161   | (true,false,true,true),(false,false,false,false) ->
    162162      let pc,b1 = next pc in
    163        ANL (`U3 (`C,`NBIT b1)), pc, 2
     163       `ANL (`U3 (`C,`NBIT b1)), pc, 2
    164164   | (true,false,true,true),(false,true,false,true) ->
    165165      let       pc,b1 = next pc in
    166166      let pc,b2 = next pc in
    167         CJNE (`U1 (`A, `DIRECT b1), `REL b2), pc, 2
     167        `CJNE (`U1 (`A, `DIRECT b1), `REL b2), pc, 2
    168168   | (true,false,true,true),(false,true,false,false) ->
    169169       let pc,b1 = next pc in
    170170       let pc,b2 = next pc in
    171          CJNE (`U1 (`A, `DATA b1), `REL b2), pc, 2
     171         `CJNE (`U1 (`A, `DATA b1), `REL b2), pc, 2
    172172   | (true,false,true,true),(true,r1,r2,r3) ->
    173173       let pc,b1 = next pc in
    174174       let pc,b2 = next pc in
    175          CJNE (`U2 (`REG(r1,r2,r3), `DATA b1), `REL b2), pc, 2
     175         `CJNE (`U2 (`REG(r1,r2,r3), `DATA b1), `REL b2), pc, 2
    176176   | (true,false,true,true),(false,true,true,i1) ->
    177177       let pc,b1 = next pc in
    178178       let pc,b2 = next pc in
    179          CJNE (`U2 (`INDIRECT i1, `DATA b1), `REL b2), pc, 2
     179         `CJNE (`U2 (`INDIRECT i1, `DATA b1), `REL b2), pc, 2
    180180   | (true,true,true,false),(false,true,false,false) ->
    181          CLR `A, pc, 1
     181         `CLR `A, pc, 1
    182182   | (true,true,false,false),(false,false,true,true) ->
    183          CLR `C, pc, 1
     183         `CLR `C, pc, 1
    184184   | (true,true,false,false),(false,false,true,false) ->
    185185       let pc,b1 = next pc in
    186          CLR (`BIT b1), pc, 1
     186         `CLR (`BIT b1), pc, 1
    187187   | (true,true,true,true),(false,true,false,false) ->
    188          CPL `A, pc, 1
     188         `CPL `A, pc, 1
    189189   | (true,false,true,true),(false,false,true,true) ->
    190          CPL `C, pc, 1
     190         `CPL `C, pc, 1
    191191   | (true,false,true,true),(false,false,true,false) ->
    192192       let pc,b1 = next pc in
    193          CPL (`BIT b1), pc, 1
     193         `CPL (`BIT b1), pc, 1
    194194   | (true,true,false,true),(false,true,false,false) ->
    195          DA `A, pc, 1
     195         `DA `A, pc, 1
    196196   | (false,false,false,true),(false,true,false,false) ->
    197          DEC `A, pc, 1
     197         `DEC `A, pc, 1
    198198   | (false,false,false,true),(true,r1,r2,r3) ->
    199          DEC (`REG(r1,r2,r3)), pc, 1
     199         `DEC (`REG(r1,r2,r3)), pc, 1
    200200   | (false,false,false,true),(false,true,false,true) ->
    201201       let pc,b1 = next pc in
    202          DEC (`DIRECT b1), pc, 1
     202         `DEC (`DIRECT b1), pc, 1
    203203   | (false,false,false,true),(false,true,true,i1) ->
    204          DEC (`INDIRECT i1), pc, 1
     204         `DEC (`INDIRECT i1), pc, 1
    205205   | (true,false,false,false),(false,true,false,false) ->
    206          DIV (`A, `B), pc, 4
     206         `DIV (`A, `B), pc, 4
    207207   | (true,true,false,true),(true,r1,r2,r3) ->
    208208       let pc,b1 = next pc in
    209          DJNZ (`REG(r1,r2,r3), `REL b1), pc, 2
     209         `DJNZ (`REG(r1,r2,r3), `REL b1), pc, 2
    210210   | (true,true,false,true),(false,true,false,true) ->
    211211       let pc,b1 = next pc in
    212212       let pc,b2 = next pc in
    213          DJNZ (`DIRECT b1, `REL b2), pc, 2
     213         `DJNZ (`DIRECT b1, `REL b2), pc, 2
    214214   | (false,false,false,false),(false,true,false,false) ->
    215          INC `A, pc, 1
     215         `INC `A, pc, 1
    216216   | (false,false,false,false),(true,r1,r2,r3) ->
    217          INC (`REG(r1,r2,r3)), pc, 1
     217         `INC (`REG(r1,r2,r3)), pc, 1
    218218   | (false,false,false,false),(false,true,false,true) ->
    219219       let pc,b1 = next pc in
    220          INC (`DIRECT b1), pc, 1
     220         `INC (`DIRECT b1), pc, 1
    221221   | (false,false,false,false),(false,true,true,i1) ->
    222          INC (`INDIRECT i1), pc, 1
     222         `INC (`INDIRECT i1), pc, 1
    223223   | (true,false,true,false),(false,false,true,true) ->
    224          INC `DPTR, pc, 2
     224         `INC `DPTR, pc, 2
    225225   | (false,false,true,false),(false,false,false,false) ->
    226226       let pc,b1 = next pc in
    227227       let pc,b2 = next pc in
    228          JB (`BIT b1, `REL b2), pc, 2
     228         `JB (`BIT b1, `REL b2), pc, 2
    229229   | (false,false,false,true),(false,false,false,false) ->
    230230       let pc,b1 = next pc in
    231231       let pc,b2 = next pc in
    232          JBC (`BIT b1, `REL b2), pc, 2
     232         `JBC (`BIT b1, `REL b2), pc, 2
    233233   | (false,true,false,false),(false,false,false,false) ->
    234234       let pc,b1 = next pc in
    235          JC (`REL b1), pc, 2
     235         `JC (`REL b1), pc, 2
    236236   | (false,true,true,true),(false,false,true,true) ->
    237          JMP `IND_DPTR, pc, 2
     237         `JMP `IND_DPTR, pc, 2
    238238   | (false,false,true,true),(false,false,false,false) ->
    239239       let pc,b1 = next pc in
    240240       let pc,b2 = next pc in
    241          JNB (`BIT b1, `REL b2), pc, 2
     241         `JNB (`BIT b1, `REL b2), pc, 2
    242242   | (false,true,false,true),(false,false,false,false) ->
    243243       let pc,b1 = next pc in
    244          JNC (`REL b1), pc, 2
     244         `JNC (`REL b1), pc, 2
    245245   | (false,true,true,true),(false,false,false,false) ->
    246246       let pc,b1 = next pc in
    247          JNZ (`REL b1), pc, 2
     247         `JNZ (`REL b1), pc, 2
    248248   | (false,true,true,false),(false,false,false,false) ->
    249249       let pc,b1 = next pc in
    250          JZ (`REL b1), pc, 2
     250         `JZ (`REL b1), pc, 2
    251251   | (false,false,false,true),(false,false,true,false) ->
    252252       let pc,b1 = next pc in
    253253       let pc,b2 = next pc in
    254          LCALL (`ADDR16 (mk_word b1 b2)), pc, 2
     254         `LCALL (`ADDR16 (mk_word b1 b2)), pc, 2
    255255   | (false,false,false,false),(false,false,true,false) ->
    256256       let pc,b1 = next pc in
    257257       let pc,b2 = next pc in
    258          LJMP (`ADDR16 (mk_word b1 b2)), pc, 2
     258         `LJMP (`ADDR16 (mk_word b1 b2)), pc, 2
    259259   | (true,true,true,false),(true,r1,r2,r3) ->
    260          MOV (`U1 (`A, `REG(r1,r2,r3))), pc, 1
     260         `MOV (`U1 (`A, `REG(r1,r2,r3))), pc, 1
    261261   | (true,true,true,false),(false,true,false,true) ->
    262262       let pc,b1 = next pc in
    263          MOV (`U1 (`A, `DIRECT b1)), pc, 1
     263         `MOV (`U1 (`A, `DIRECT b1)), pc, 1
    264264   | (true,true,true,false),(false,true,true,i1) ->
    265          MOV (`U1 (`A, `INDIRECT i1)), pc, 1
     265         `MOV (`U1 (`A, `INDIRECT i1)), pc, 1
    266266   | (false,true,true,true),(false,true,false,false) ->
    267267       let pc,b1 = next pc in
    268          MOV (`U1 (`A, `DATA b1)), pc, 1
     268         `MOV (`U1 (`A, `DATA b1)), pc, 1
    269269   | (true,true,true,true),(true,r1,r2,r3) ->
    270          MOV (`U2 (`REG(r1,r2,r3), `A)), pc, 1
     270         `MOV (`U2 (`REG(r1,r2,r3), `A)), pc, 1
    271271   | (true,false,true,false),(true,r1,r2,r3) ->
    272272       let pc,b1 = next pc in
    273          MOV (`U2 (`REG(r1,r2,r3), (`DIRECT b1))), pc, 2
     273         `MOV (`U2 (`REG(r1,r2,r3), (`DIRECT b1))), pc, 2
    274274   | (false,true,true,true),(true,r1,r2,r3) ->
    275275       let pc,b1 = next pc in
    276          MOV (`U2 (`REG(r1,r2,r3), (`DATA b1))), pc, 1
     276         `MOV (`U2 (`REG(r1,r2,r3), (`DATA b1))), pc, 1
    277277   | (true,true,true,true),(false,true,false,true) ->
    278278       let pc,b1 = next pc in
    279          MOV (`U3 (`DIRECT b1, `A)), pc, 1
     279         `MOV (`U3 (`DIRECT b1, `A)), pc, 1
    280280   | (true,false,false,false),(true,r1,r2,r3) ->
    281281       let pc,b1 = next pc in
    282          MOV (`U3 (`DIRECT b1, `REG(r1,r2,r3))), pc, 2
     282         `MOV (`U3 (`DIRECT b1, `REG(r1,r2,r3))), pc, 2
    283283   | (true,false,false,false),(false,true,false,true) ->
    284284       let pc,b1 = next pc in
    285285       let pc,b2 = next pc in
    286          MOV (`U3 (`DIRECT b1, `DIRECT b2)), pc, 2
     286         `MOV (`U3 (`DIRECT b1, `DIRECT b2)), pc, 2
    287287   | (true,false,false,false),(false,true,true,i1) ->
    288288       let pc,b1 = next pc in
    289          MOV (`U3 (`DIRECT b1, `INDIRECT i1)), pc, 2
     289         `MOV (`U3 (`DIRECT b1, `INDIRECT i1)), pc, 2
    290290   | (false,true,true,true),(false,true,false,true) ->
    291291       let pc,b1 = next pc in
    292292       let pc,b2 = next pc in
    293          MOV (`U3 (`DIRECT b1, `DATA b2)), pc, 2
     293         `MOV (`U3 (`DIRECT b1, `DATA b2)), pc, 2
    294294   | (true,true,true,true),(false,true,true,i1) ->
    295          MOV (`U2 (`INDIRECT i1, `A)), pc, 1
     295         `MOV (`U2 (`INDIRECT i1, `A)), pc, 1
    296296   | (true,false,true,false),(false,true,true,i1) ->
    297297       let pc,b1 = next pc in
    298          MOV (`U2 (`INDIRECT i1, `DIRECT b1)), pc, 2
     298         `MOV (`U2 (`INDIRECT i1, `DIRECT b1)), pc, 2
    299299   | (false,true,true,true),(false,true,true,i1) ->
    300300       let pc,b1 = next pc in
    301          MOV (`U2 (`INDIRECT i1, `DATA b1)), pc, 1
     301         `MOV (`U2 (`INDIRECT i1, `DATA b1)), pc, 1
    302302   | (true,false,true,false),(false,false,true,false) ->
    303303       let pc,b1 = next pc in
    304          MOV (`U5 (`C, `BIT b1)), pc, 1
     304         `MOV (`U5 (`C, `BIT b1)), pc, 1
    305305   | (true,false,false,true),(false,false,true,false) ->
    306306       let pc,b1 = next pc in
    307          MOV (`U6 (`BIT b1, `C)), pc, 2
     307         `MOV (`U6 (`BIT b1, `C)), pc, 2
    308308   | (true,false,false,true),(false,false,false,false) ->
    309309       let pc,b1 = next pc in
    310310       let pc,b2 = next pc in
    311          MOV (`U4 (`DPTR, `DATA16(mk_word b1 b2))), pc, 2
     311         `MOV (`U4 (`DPTR, `DATA16(mk_word b1 b2))), pc, 2
    312312   | (true,false,false,true),(false,false,true,true) ->
    313          MOVC (`A, `A_DPTR), pc, 2
     313         `MOVC (`A, `A_DPTR), pc, 2
    314314   | (true,false,false,false),(false,false,true,true) ->
    315          MOVC (`A, `A_PC), pc, 2
     315         `MOVC (`A, `A_PC), pc, 2
    316316   | (true,true,true,false),(false,false,true,i1) ->
    317          MOVX (`U1 (`A, `EXT_INDIRECT i1)), pc, 2
     317         `MOVX (`U1 (`A, `EXT_INDIRECT i1)), pc, 2
    318318   | (true,true,true,false),(false,false,false,false) ->
    319          MOVX (`U1 (`A, `EXT_IND_DPTR)), pc, 2
     319         `MOVX (`U1 (`A, `EXT_IND_DPTR)), pc, 2
    320320   | (true,true,true,true),(false,false,true,i1) ->
    321          MOVX (`U2 (`EXT_INDIRECT i1, `A)), pc, 2
     321         `MOVX (`U2 (`EXT_INDIRECT i1, `A)), pc, 2
    322322   | (true,true,true,true),(false,false,false,false) ->
    323          MOVX (`U2 (`EXT_IND_DPTR, `A)), pc, 2
     323         `MOVX (`U2 (`EXT_IND_DPTR, `A)), pc, 2
    324324   | (true,false,true,false),(false,true,false,false) ->
    325          MUL(`A, `B), pc, 4
     325         `MUL(`A, `B), pc, 4
    326326   | (false,false,false,false),(false,false,false,false) ->
    327          NOP, pc, 1
     327         `NOP, pc, 1
    328328   | (false,true,false,false),(true,r1,r2,r3) ->
    329          ORL (`U1(`A, `REG(r1,r2,r3))), pc, 1
     329         `ORL (`U1(`A, `REG(r1,r2,r3))), pc, 1
    330330   | (false,true,false,false),(false,true,false,true) ->
    331331       let pc,b1 = next pc in
    332          ORL (`U1(`A, `DIRECT b1)), pc, 1
     332         `ORL (`U1(`A, `DIRECT b1)), pc, 1
    333333   | (false,true,false,false),(false,true,true,i1) ->
    334          ORL (`U1(`A, `INDIRECT i1)), pc, 1
     334         `ORL (`U1(`A, `INDIRECT i1)), pc, 1
    335335   | (false,true,false,false),(false,true,false,false) ->
    336336       let pc,b1 = next pc in
    337          ORL (`U1(`A, `DATA b1)), pc, 1
     337         `ORL (`U1(`A, `DATA b1)), pc, 1
    338338   | (false,true,false,false),(false,false,true,false) ->
    339339       let pc,b1 = next pc in
    340          ORL (`U2(`DIRECT b1, `A)), pc, 1
     340         `ORL (`U2(`DIRECT b1, `A)), pc, 1
    341341   | (false,true,false,false),(false,false,true,true) ->
    342342       let pc,b1 = next pc in
    343343       let pc,b2 = next pc in
    344          ORL (`U2 (`DIRECT b1, `DATA b2)), pc, 2
     344         `ORL (`U2 (`DIRECT b1, `DATA b2)), pc, 2
    345345   | (false,true,true,true),(false,false,true,false) ->
    346346       let pc,b1 = next pc in
    347          ORL (`U3 (`C, `BIT b1)), pc, 2
     347         `ORL (`U3 (`C, `BIT b1)), pc, 2
    348348   | (true,false,true,false),(false,false,false,false) ->
    349349       let pc,b1 = next pc in
    350          ORL (`U3 (`C, `NBIT b1)), pc, 2
     350         `ORL (`U3 (`C, `NBIT b1)), pc, 2
    351351   | (true,true,false,true),(false,false,false,false) ->
    352352       let pc,b1 = next pc in
    353          POP (`DIRECT b1), pc, 2
     353         `POP (`DIRECT b1), pc, 2
    354354   | (true,true,false,false),(false,false,false,false) ->
    355355       let pc,b1 = next pc in
    356          PUSH (`DIRECT b1), pc, 2
     356         `PUSH (`DIRECT b1), pc, 2
    357357   | (false,false,true,false),(false,false,true,false) ->
    358          RET, pc, 2
     358         `RET, pc, 2
    359359   | (false,false,true,true),(false,false,true,false) ->
    360          RETI, pc, 2
     360         `RETI, pc, 2
    361361   | (false,false,true,false),(false,false,true,true) ->
    362          RL `A, pc, 1
     362         `RL `A, pc, 1
    363363   | (false,false,true,true),(false,false,true,true) ->
    364          RLC `A, pc, 1
     364         `RLC `A, pc, 1
    365365   | (false,false,false,false),(false,false,true,true) ->
    366          RR `A, pc, 1
     366         `RR `A, pc, 1
    367367   | (false,false,false,true),(false,false,true,true) ->
    368          RRC `A, pc, 1
     368         `RRC `A, pc, 1
    369369   | (true,true,false,true),(false,false,true,true) ->
    370          SETB `C, pc, 1
     370         `SETB `C, pc, 1
    371371   | (true,true,false,true),(false,false,true,false) ->
    372372       let pc,b1 = next pc in
    373          SETB (`BIT b1), pc, 1
     373         `SETB (`BIT b1), pc, 1
    374374   | (true,false,false,false),(false,false,false,false) ->
    375375       let pc,b1 = next pc in
    376          SJMP (`REL b1), pc, 2
     376         `SJMP (`REL b1), pc, 2
    377377   | (true,false,false,true),(true,r1,r2,r3) ->
    378        SUBB (`A, `REG(r1,r2,r3)), pc, 1
     378       `SUBB (`A, `REG(r1,r2,r3)), pc, 1
    379379   | (true,false,false,true),(false,true,false,true) ->
    380380       let pc,b1 = next pc in
    381          SUBB (`A, `DIRECT b1), pc, 1
     381         `SUBB (`A, `DIRECT b1), pc, 1
    382382   | (true,false,false,true),(false,true,true,i1) ->
    383          SUBB (`A, `INDIRECT i1), pc, 1
     383         `SUBB (`A, `INDIRECT i1), pc, 1
    384384   | (true,false,false,true),(false,true,false,false) ->
    385385       let pc,b1 = next pc in
    386          SUBB (`A, `DATA b1), pc, 1
     386         `SUBB (`A, `DATA b1), pc, 1
    387387   | (true,true,false,false),(false,true,false,false) ->
    388          SWAP `A, pc, 1
     388         `SWAP `A, pc, 1
    389389   | (true,true,false,false),(true,r1,r2,r3) ->
    390          XCH (`A, `REG(r1,r2,r3)), pc, 1
     390         `XCH (`A, `REG(r1,r2,r3)), pc, 1
    391391   | (true,true,false,false),(false,true,false,true) ->
    392392       let pc,b1 = next pc in
    393          XCH (`A, `DIRECT b1), pc, 1
     393         `XCH (`A, `DIRECT b1), pc, 1
    394394   | (true,true,false,false),(false,true,true,i1) ->
    395          XCH (`A, `INDIRECT i1), pc, 1
     395         `XCH (`A, `INDIRECT i1), pc, 1
    396396   | (true,true,false,true),(false,true,true,i1) ->
    397          XCHD(`A, `INDIRECT i1), pc, 1
     397         `XCHD(`A, `INDIRECT i1), pc, 1
    398398   | (false,true,true,false),(true,r1,r2,r3) ->
    399          XRL(`U1(`A, `REG(r1,r2,r3))), pc, 1
     399         `XRL(`U1(`A, `REG(r1,r2,r3))), pc, 1
    400400   | (false,true,true,false),(false,true,false,true) ->
    401401       let pc,b1 = next pc in
    402          XRL(`U1(`A, `DIRECT b1)), pc, 1
     402         `XRL(`U1(`A, `DIRECT b1)), pc, 1
    403403   | (false,true,true,false),(false,true,true,i1) ->
    404          XRL(`U1(`A, `INDIRECT i1)), pc, 1
     404         `XRL(`U1(`A, `INDIRECT i1)), pc, 1
    405405   | (false,true,true,false),(false,true,false,false) ->
    406406       let pc,b1 = next pc in
    407          XRL(`U1(`A, `DATA b1)), pc, 1
     407         `XRL(`U1(`A, `DATA b1)), pc, 1
    408408   | (false,true,true,false),(false,false,true,false) ->
    409409       let pc,b1 = next pc in
    410          XRL(`U2(`DIRECT b1, `A)), pc, 1
     410         `XRL(`U2(`DIRECT b1, `A)), pc, 1
    411411   | (false,true,true,false),(false,false,true,true) ->
    412412       let pc,b1 = next pc in
    413413       let pc,b2 = next pc in
    414          XRL(`U2(`DIRECT b1, `DATA b2)), pc, 2
     414         `XRL(`U2(`DIRECT b1, `DATA b2)), pc, 2
     415   | _,_ -> assert false
    415416 with
    416417  Not_found -> raise (Fetch_exception "Key not found")
    417418;;
    418419
    419 let lift a f g =
    420   let (x, y) = f a in
    421     (g x, g y)
    422 
    423420let assembly1 =
    424421 function
    425     ACALL (`ADDR11 w) ->
     422    `ACALL (`ADDR11 w) ->
    426423      let (a10,a9,a8,b1) = from_word11 w in
    427424        [mk_byte_from_bits ((a10,a9,a8,true),(false,false,false,true)); b1]
    428   | ADD (`A,`REG (r1,r2,r3)) ->
     425  | `ADD (`A,`REG (r1,r2,r3)) ->
    429426     [mk_byte_from_bits ((false,false,true,false),(true,r1,r2,r3))]
    430   | ADD (`A, `DIRECT b1) ->
     427  | `ADD (`A, `DIRECT b1) ->
    431428     [mk_byte_from_bits ((false,false,true,false),(false,true,false,true)); b1]
    432   | ADD (`A, `INDIRECT i1) ->
     429  | `ADD (`A, `INDIRECT i1) ->
    433430     [mk_byte_from_bits ((false,false,true,false),(false,true,true,i1))]
    434   | ADD (`A, `DATA b1) ->
     431  | `ADD (`A, `DATA b1) ->
    435432     [mk_byte_from_bits ((false,false,true,false),(false,true,false,false)); b1]
    436   | ADDC (`A, `REG(r1,r2,r3)) ->
     433  | `ADDC (`A, `REG(r1,r2,r3)) ->
    437434     [mk_byte_from_bits ((false,false,true,true),(true,r1,r2,r3))]
    438   | ADDC (`A, `DIRECT b1) ->
     435  | `ADDC (`A, `DIRECT b1) ->
    439436     [mk_byte_from_bits ((false,false,true,true),(false,true,false,true)); b1]
    440   | ADDC (`A,`INDIRECT i1) ->
     437  | `ADDC (`A,`INDIRECT i1) ->
    441438     [mk_byte_from_bits ((false,false,true,true),(false,true,true,i1))]
    442   | ADDC (`A,`DATA b1) ->
     439  | `ADDC (`A,`DATA b1) ->
    443440     [mk_byte_from_bits ((false,false,true,true),(false,true,false,false)); b1]
    444   | AJMP (`ADDR11 w) ->
     441  | `AJMP (`ADDR11 w) ->
    445442     let (a10,a9,a8,b1) = from_word11 w in
    446443       [mk_byte_from_bits ((a10,a9,a8,false),(false,false,false,true))]
    447   | ANL (`U1 (`A, `REG (r1,r2,r3))) ->
     444  | `ANL (`U1 (`A, `REG (r1,r2,r3))) ->
    448445     [mk_byte_from_bits ((false,true,false,true),(true,r1,r2,r3))]
    449   | ANL (`U1 (`A, `DIRECT b1)) ->
     446  | `ANL (`U1 (`A, `DIRECT b1)) ->
    450447     [mk_byte_from_bits ((false,true,false,true),(false,true,false,true)); b1]
    451   | ANL (`U1 (`A, `INDIRECT i1)) ->
     448  | `ANL (`U1 (`A, `INDIRECT i1)) ->
    452449     [mk_byte_from_bits ((false,true,false,true),(false,true,true,i1))]
    453   | ANL (`U1 (`A, `DATA b1)) ->
     450  | `ANL (`U1 (`A, `DATA b1)) ->
    454451     [mk_byte_from_bits ((false,true,false,true),(false,true,false,false)); b1]
    455   | ANL (`U2 (`DIRECT b1,`A)) ->
     452  | `ANL (`U2 (`DIRECT b1,`A)) ->
    456453     [mk_byte_from_bits ((false,true,false,true),(false,false,true,false)); b1]
    457   | ANL (`U2 (`DIRECT b1,`DATA b2)) ->
     454  | `ANL (`U2 (`DIRECT b1,`DATA b2)) ->
    458455     [mk_byte_from_bits ((false,true,false,true),(false,false,true,true)); b1; b2]
    459   | ANL (`U3 (`C,`BIT b1)) ->
     456  | `ANL (`U3 (`C,`BIT b1)) ->
    460457     [mk_byte_from_bits ((true,false,false,false),(false,false,true,false)); b1]
    461   | ANL (`U3 (`C,`NBIT b1)) ->
     458  | `ANL (`U3 (`C,`NBIT b1)) ->
    462459    [mk_byte_from_bits ((true,false,true,true),(false,false,false,false)); b1]
    463   | CJNE (`U1 (`A, `DIRECT b1), `REL b2) ->
     460  | `CJNE (`U1 (`A, `DIRECT b1), `REL b2) ->
    464461    [mk_byte_from_bits ((true,false,true,true),(false,true,false,true)); b1; b2]
    465   | CJNE (`U1 (`A, `DATA b1), `REL b2) ->
     462  | `CJNE (`U1 (`A, `DATA b1), `REL b2) ->
    466463    [mk_byte_from_bits ((true,false,true,true),(false,true,false,false)); b1; b2]
    467   | CJNE (`U2 (`REG(r1,r2,r3), `DATA b1), `REL b2) ->
     464  | `CJNE (`U2 (`REG(r1,r2,r3), `DATA b1), `REL b2) ->
    468465    [mk_byte_from_bits ((true,false,true,true),(true,r1,r2,r3)); b1; b2]
    469   | CJNE (`U2 (`INDIRECT i1, `DATA b1), `REL b2) ->
     466  | `CJNE (`U2 (`INDIRECT i1, `DATA b1), `REL b2) ->
    470467    [mk_byte_from_bits ((true,false,true,true),(false,true,true,i1)); b1; b2]
    471   | CLR `A ->
     468  | `CLR `A ->
    472469    [mk_byte_from_bits ((true,true,true,false),(false,true,false,false))]
    473   | CLR `C ->
     470  | `CLR `C ->
    474471    [mk_byte_from_bits ((true,true,false,false),(false,false,true,true))]
    475   | CLR (`BIT b1) ->
     472  | `CLR (`BIT b1) ->
    476473    [mk_byte_from_bits ((true,true,false,false),(false,false,true,false)); b1]
    477   | CPL `A ->
     474  | `CPL `A ->
    478475    [mk_byte_from_bits ((true,true,true,true),(false,true,false,false))]
    479   | CPL `C ->
     476  | `CPL `C ->
    480477    [mk_byte_from_bits ((true,false,true,true),(false,false,true,true))]
    481   | CPL (`BIT b1) ->
     478  | `CPL (`BIT b1) ->
    482479    [mk_byte_from_bits ((true,false,true,true),(false,false,true,false)); b1]
    483   | DA `A ->
     480  | `DA `A ->
    484481    [mk_byte_from_bits ((true,true,false,true),(false,true,false,false))]
    485   | DEC `A ->
     482  | `DEC `A ->
    486483    [mk_byte_from_bits ((false,false,false,true),(false,true,false,false))]
    487   | DEC (`REG(r1,r2,r3)) ->
     484  | `DEC (`REG(r1,r2,r3)) ->
    488485    [mk_byte_from_bits ((false,false,false,true),(true,r1,r2,r3))]
    489   | DEC (`DIRECT b1) ->
     486  | `DEC (`DIRECT b1) ->
    490487    [mk_byte_from_bits ((false,false,false,true),(false,true,false,true)); b1]
    491   | DEC (`INDIRECT i1) ->
     488  | `DEC (`INDIRECT i1) ->
    492489    [mk_byte_from_bits ((false,false,false,true),(false,true,true,i1))]
    493   | DIV (`A, `B) ->
     490  | `DIV (`A, `B) ->
    494491    [mk_byte_from_bits ((true,false,false,false),(false,true,false,false))]
    495   | DJNZ (`REG(r1,r2,r3), `REL b1) ->
     492  | `DJNZ (`REG(r1,r2,r3), `REL b1) ->
    496493    [mk_byte_from_bits ((true,true,false,true),(true,r1,r2,r3)); b1]
    497   | DJNZ (`DIRECT b1, `REL b2) ->
     494  | `DJNZ (`DIRECT b1, `REL b2) ->
    498495    [mk_byte_from_bits ((true,true,false,true),(false,true,false,true)); b1; b2]
    499   | INC `A ->
     496  | `INC `A ->
    500497    [mk_byte_from_bits ((false,false,false,false),(false,true,false,false))]
    501   | INC (`REG(r1,r2,r3)) ->
     498  | `INC (`REG(r1,r2,r3)) ->
    502499    [mk_byte_from_bits ((false,false,false,false),(true,r1,r2,r3))]
    503   | INC (`DIRECT b1) ->
     500  | `INC (`DIRECT b1) ->
    504501    [mk_byte_from_bits ((false,false,false,false),(false,true,false,true)); b1]
    505   | INC (`INDIRECT i1) ->
     502  | `INC (`INDIRECT i1) ->
    506503    [mk_byte_from_bits ((false,false,false,false),(false,true,true,i1))]
    507   | INC `DPTR ->
     504  | `INC `DPTR ->
    508505    [mk_byte_from_bits ((true,false,true,false),(false,false,true,true))]
    509   | JB (`BIT b1, `REL b2) ->
     506  | `JB (`BIT b1, `REL b2) ->
    510507    [mk_byte_from_bits ((false,false,true,false),(false,false,false,false)); b1; b2]
    511   | JBC (`BIT b1, `REL b2) ->
     508  | `JBC (`BIT b1, `REL b2) ->
    512509    [mk_byte_from_bits ((false,false,false,true),(false,false,false,false)); b1; b2]
    513   | JC (`REL b1) ->
     510  | `JC (`REL b1) ->
    514511    [mk_byte_from_bits ((false,true,false,false),(false,false,false,false)); b1]
    515   | JMP `IND_DPTR ->
     512  | `JMP `IND_DPTR ->
    516513    [mk_byte_from_bits ((false,true,true,true),(false,false,true,true))]
    517   | JNB (`BIT b1, `REL b2) ->
     514  | `JNB (`BIT b1, `REL b2) ->
    518515    [mk_byte_from_bits ((false,false,true,true),(false,false,false,false)); b1; b2]
    519   | JNC (`REL b1) ->
     516  | `JNC (`REL b1) ->
    520517    [mk_byte_from_bits ((false,true,false,true),(false,false,false,false)); b1]
    521   | JNZ (`REL b1) ->
     518  | `JNZ (`REL b1) ->
    522519    [mk_byte_from_bits ((false,true,true,true),(false,false,false,false)); b1]
    523   | JZ (`REL b1) ->
     520  | `JZ (`REL b1) ->
    524521    [mk_byte_from_bits ((false,true,true,false),(false,false,false,false)); b1]
    525   | LCALL (`ADDR16 w) ->
     522  | `LCALL (`ADDR16 w) ->
    526523      let (b1,b2) = from_word w in
    527524        [mk_byte_from_bits ((false,false,false,true),(false,false,true,false)); b1; b2]
    528   | LJMP (`ADDR16 w) ->
     525  | `LJMP (`ADDR16 w) ->
    529526      let (b1,b2) = from_word w in
    530527        [mk_byte_from_bits ((false,false,false,false),(false,false,true,false)); b1; b2]
    531   | MOV (`U1 (`A, `REG(r1,r2,r3))) ->
     528  | `MOV (`U1 (`A, `REG(r1,r2,r3))) ->
    532529    [mk_byte_from_bits ((true,true,true,false),(true,r1,r2,r3))]
    533   | MOV (`U1 (`A, `DIRECT b1)) ->
     530  | `MOV (`U1 (`A, `DIRECT b1)) ->
    534531    [mk_byte_from_bits ((true,true,true,false),(false,true,false,true)); b1]
    535   | MOV (`U1 (`A, `INDIRECT i1)) ->
     532  | `MOV (`U1 (`A, `INDIRECT i1)) ->
    536533    [mk_byte_from_bits ((true,true,true,false),(false,true,true,i1))]
    537   | MOV (`U1 (`A, `DATA b1)) ->
     534  | `MOV (`U1 (`A, `DATA b1)) ->
    538535    [mk_byte_from_bits ((false,true,true,true),(false,true,false,false)); b1]
    539   | MOV (`U2 (`REG(r1,r2,r3), `A)) ->
     536  | `MOV (`U2 (`REG(r1,r2,r3), `A)) ->
    540537    [mk_byte_from_bits ((true,true,true,true),(true,r1,r2,r3))]
    541   | MOV (`U2 (`REG(r1,r2,r3), (`DIRECT b1))) ->
     538  | `MOV (`U2 (`REG(r1,r2,r3), (`DIRECT b1))) ->
    542539    [mk_byte_from_bits ((true,false,true,false),(true,r1,r2,r3)); b1]
    543   | MOV (`U2 (`REG(r1,r2,r3), (`DATA b1))) ->
     540  | `MOV (`U2 (`REG(r1,r2,r3), (`DATA b1))) ->
    544541    [mk_byte_from_bits ((false,true,true,true),(true,r1,r2,r3)); b1]
    545   | MOV (`U3 (`DIRECT b1, `A)) ->
     542  | `MOV (`U3 (`DIRECT b1, `A)) ->
    546543    [mk_byte_from_bits ((true,true,true,true),(false,true,false,true)); b1]
    547   | MOV (`U3 (`DIRECT b1, `REG(r1,r2,r3))) ->
     544  | `MOV (`U3 (`DIRECT b1, `REG(r1,r2,r3))) ->
    548545    [mk_byte_from_bits ((true,false,false,false),(true,r1,r2,r3)); b1]
    549   | MOV (`U3 (`DIRECT b1, `DIRECT b2)) ->
     546  | `MOV (`U3 (`DIRECT b1, `DIRECT b2)) ->
    550547    [mk_byte_from_bits ((true,false,false,false),(false,true,false,true)); b1; b2]
    551   | MOV (`U3 (`DIRECT b1, `INDIRECT i1)) ->
     548  | `MOV (`U3 (`DIRECT b1, `INDIRECT i1)) ->
    552549    [mk_byte_from_bits ((true,false,false,false),(false,true,true,i1)); b1]
    553   | MOV (`U3 (`DIRECT b1, `DATA b2)) ->
     550  | `MOV (`U3 (`DIRECT b1, `DATA b2)) ->
    554551    [mk_byte_from_bits ((false,true,true,true),(false,true,false,true)); b1; b2]
    555   | MOV (`U2 (`INDIRECT i1, `A)) ->
     552  | `MOV (`U2 (`INDIRECT i1, `A)) ->
    556553    [mk_byte_from_bits ((true,true,true,true),(false,true,true,i1))]
    557   | MOV (`U2 (`INDIRECT i1, `DIRECT b1)) ->
     554  | `MOV (`U2 (`INDIRECT i1, `DIRECT b1)) ->
    558555    [mk_byte_from_bits ((true,false,true,false),(false,true,true,i1)); b1]
    559   | MOV (`U2 (`INDIRECT i1, `DATA b1)) ->
     556  | `MOV (`U2 (`INDIRECT i1, `DATA b1)) ->
    560557    [mk_byte_from_bits ((false,true,true,true),(false,true,true,i1)); b1]
    561   | MOV (`U5 (`C, `BIT b1)) ->
     558  | `MOV (`U5 (`C, `BIT b1)) ->
    562559    [mk_byte_from_bits ((true,false,true,false),(false,false,true,false)); b1]
    563   | MOV (`U6 (`BIT b1, `C)) ->
     560  | `MOV (`U6 (`BIT b1, `C)) ->
    564561    [mk_byte_from_bits ((true,false,false,true),(false,false,true,false)); b1]
    565   | MOV (`U4 (`DPTR, `DATA16 w)) ->
     562  | `MOV (`U4 (`DPTR, `DATA16 w)) ->
    566563    let (b1,b2) = from_word w in
    567564      [mk_byte_from_bits ((true,false,false,true),(false,false,false,false)); b1; b2]
    568   | MOVC (`A, `A_DPTR) ->
     565  | `MOVC (`A, `A_DPTR) ->
    569566    [mk_byte_from_bits ((true,false,false,true),(false,false,true,true))]
    570   | MOVC (`A, `A_PC) ->
     567  | `MOVC (`A, `A_PC) ->
    571568    [mk_byte_from_bits ((true,false,false,false),(false,false,true,true))]
    572   | MOVX (`U1 (`A, `EXT_INDIRECT i1)) ->
     569  | `MOVX (`U1 (`A, `EXT_INDIRECT i1)) ->
    573570    [mk_byte_from_bits ((true,true,true,false),(false,false,true,i1))]
    574   | MOVX (`U1 (`A, `EXT_IND_DPTR)) ->
     571  | `MOVX (`U1 (`A, `EXT_IND_DPTR)) ->
    575572    [mk_byte_from_bits ((true,true,true,false),(false,false,false,false))]
    576   | MOVX (`U2 (`EXT_INDIRECT i1, `A)) ->
     573  | `MOVX (`U2 (`EXT_INDIRECT i1, `A)) ->
    577574    [mk_byte_from_bits ((true,true,true,true),(false,false,true,i1))]
    578   | MOVX (`U2 (`EXT_IND_DPTR, `A)) ->
     575  | `MOVX (`U2 (`EXT_IND_DPTR, `A)) ->
    579576    [mk_byte_from_bits ((true,true,true,true),(false,false,false,false))]
    580   | MUL(`A, `B) ->
     577  | `MUL(`A, `B) ->
    581578    [mk_byte_from_bits ((true,false,true,false),(false,true,false,false))]
    582   | NOP ->
     579  | `NOP ->
    583580    [mk_byte_from_bits ((false,false,false,false),(false,false,false,false))]
    584   | ORL (`U1(`A, `REG(r1,r2,r3))) ->
     581  | `ORL (`U1(`A, `REG(r1,r2,r3))) ->
    585582    [mk_byte_from_bits ((false,true,false,false),(true,r1,r2,r3))]
    586   | ORL (`U1(`A, `DIRECT b1)) ->
     583  | `ORL (`U1(`A, `DIRECT b1)) ->
    587584    [mk_byte_from_bits ((false,true,false,false),(false,true,false,true)); b1]
    588   | ORL (`U1(`A, `INDIRECT i1)) ->
     585  | `ORL (`U1(`A, `INDIRECT i1)) ->
    589586    [mk_byte_from_bits ((false,true,false,false),(false,true,true,i1))]
    590   | ORL (`U1(`A, `DATA b1)) ->
     587  | `ORL (`U1(`A, `DATA b1)) ->
    591588    [mk_byte_from_bits ((false,true,false,false),(false,true,false,false)); b1]
    592   | ORL (`U2(`DIRECT b1, `A)) ->
     589  | `ORL (`U2(`DIRECT b1, `A)) ->
    593590    [mk_byte_from_bits ((false,true,false,false),(false,false,true,false)); b1]
    594   | ORL (`U2 (`DIRECT b1, `DATA b2)) ->
     591  | `ORL (`U2 (`DIRECT b1, `DATA b2)) ->
    595592    [mk_byte_from_bits ((false,true,false,false),(false,false,true,true)); b1; b2]
    596   | ORL (`U3 (`C, `BIT b1)) ->
     593  | `ORL (`U3 (`C, `BIT b1)) ->
    597594    [mk_byte_from_bits ((false,true,true,true),(false,false,true,false)); b1]
    598   | ORL (`U3 (`C, `NBIT b1)) ->
     595  | `ORL (`U3 (`C, `NBIT b1)) ->
    599596    [mk_byte_from_bits ((true,false,true,false),(false,false,false,false)); b1]
    600   | POP (`DIRECT b1) ->
     597  | `POP (`DIRECT b1) ->
    601598    [mk_byte_from_bits ((true,true,false,true),(false,false,false,false)); b1]
    602   | PUSH (`DIRECT b1) ->
     599  | `PUSH (`DIRECT b1) ->
    603600    [mk_byte_from_bits ((true,true,false,false),(false,false,false,false)); b1]
    604   | RET ->
     601  | `RET ->
    605602    [mk_byte_from_bits ((false,false,true,false),(false,false,true,false))]
    606   | RETI ->
     603  | `RETI ->
    607604    [mk_byte_from_bits ((false,false,true,true),(false,false,true,false))]
    608   | RL `A ->
     605  | `RL `A ->
    609606    [mk_byte_from_bits ((false,false,true,false),(false,false,true,true))]
    610   | RLC `A ->
     607  | `RLC `A ->
    611608    [mk_byte_from_bits ((false,false,true,true),(false,false,true,true))]
    612   | RR `A ->
     609  | `RR `A ->
    613610    [mk_byte_from_bits ((false,false,false,false),(false,false,true,true))]
    614   | RRC `A ->
     611  | `RRC `A ->
    615612    [mk_byte_from_bits ((false,false,false,true),(false,false,true,true))]
    616   | SETB `C ->
     613  | `SETB `C ->
    617614    [mk_byte_from_bits ((true,true,false,true),(false,false,true,true))]
    618   | SETB (`BIT b1) ->
     615  | `SETB (`BIT b1) ->
    619616    [mk_byte_from_bits ((true,true,false,true),(false,false,true,false)); b1]
    620   | SJMP (`REL b1) ->
     617  | `SJMP (`REL b1) ->
    621618    [mk_byte_from_bits ((true,false,false,false),(false,false,false,false)); b1]
    622   | SUBB (`A, `REG(r1,r2,r3)) ->
     619  | `SUBB (`A, `REG(r1,r2,r3)) ->
    623620    [mk_byte_from_bits ((true,false,false,true),(true,r1,r2,r3))]
    624   | SUBB (`A, `DIRECT b1) ->
     621  | `SUBB (`A, `DIRECT b1) ->
    625622    [mk_byte_from_bits ((true,false,false,true),(false,true,false,true)); b1]
    626   | SUBB (`A, `INDIRECT i1) ->
     623  | `SUBB (`A, `INDIRECT i1) ->
    627624    [mk_byte_from_bits ((true,false,false,true),(false,true,true,i1))]
    628   | SUBB (`A, `DATA b1) ->
     625  | `SUBB (`A, `DATA b1) ->
    629626    [mk_byte_from_bits ((true,false,false,true),(false,true,false,false)); b1]
    630   | SWAP `A ->
     627  | `SWAP `A ->
    631628    [mk_byte_from_bits ((true,true,false,false),(false,true,false,false))]
    632   | XCH (`A, `REG(r1,r2,r3)) ->
     629  | `XCH (`A, `REG(r1,r2,r3)) ->
    633630    [mk_byte_from_bits ((true,true,false,false),(true,r1,r2,r3))]
    634   | XCH (`A, `DIRECT b1) ->
     631  | `XCH (`A, `DIRECT b1) ->
    635632    [mk_byte_from_bits ((true,true,false,false),(false,true,false,true)); b1]
    636   | XCH (`A, `INDIRECT i1) ->
     633  | `XCH (`A, `INDIRECT i1) ->
    637634    [mk_byte_from_bits ((true,true,false,false),(false,true,true,i1))]
    638   | XCHD(`A, `INDIRECT i1) ->
     635  | `XCHD(`A, `INDIRECT i1) ->
    639636    [mk_byte_from_bits ((true,true,false,true),(false,true,true,i1))]
    640   | XRL(`U1(`A, `REG(r1,r2,r3))) ->
     637  | `XRL(`U1(`A, `REG(r1,r2,r3))) ->
    641638    [mk_byte_from_bits ((false,true,true,false),(true,r1,r2,r3))]
    642   | XRL(`U1(`A, `DIRECT b1)) ->
     639  | `XRL(`U1(`A, `DIRECT b1)) ->
    643640    [mk_byte_from_bits ((false,true,true,false),(false,true,false,true)); b1]
    644   | XRL(`U1(`A, `INDIRECT i1)) ->
     641  | `XRL(`U1(`A, `INDIRECT i1)) ->
    645642    [mk_byte_from_bits ((false,true,true,false),(false,true,true,i1))]
    646   | XRL(`U1(`A, `DATA b1)) ->
     643  | `XRL(`U1(`A, `DATA b1)) ->
    647644    [mk_byte_from_bits ((false,true,true,false),(false,true,false,false)); b1]
    648   | XRL(`U2(`DIRECT b1, `A)) ->
     645  | `XRL(`U2(`DIRECT b1, `A)) ->
    649646    [mk_byte_from_bits ((false,true,true,false),(false,false,true,false)); b1]
    650   | XRL(`U2(`DIRECT b1, `DATA b2)) ->
     647  | `XRL(`U2(`DIRECT b1, `DATA b2)) ->
    651648    [mk_byte_from_bits ((false,true,true,false),(false,false,true,true)); b1; b2]
    652649;;
  • Deliverables/D4.1/BitVectors.ml

    r95 r97  
    2020    b1::b2::b3::b4::r -> [b1;b2;b3;b4],r
    2121  | _ -> assert false
     22let bits_of_byte =
     23 function
     24    [b1;b2;b3;b4;b5;b6;b7;b8] -> (b1,b2,b3,b4),(b5,b6,b7,b8)
     25  | _ -> assert false
    2226let mk_byte7 b1 b2 b3 n1 = b1::b2::b3::n1
    2327let from_byte7 =
     
    3236let mk_word11 = mk_byte7
    3337let from_word11 = from_byte7
    34 
    35 let to_bits l = l
    3638
    3739let get_bit index l =
  • Deliverables/D4.1/BitVectors.mli

    r95 r97  
    1818val mk_byte_from_bits: ((bit * bit * bit * bit) * (bit * bit * bit * bit)) -> byte
    1919val from_byte: byte -> nibble * nibble
     20val bits_of_byte: byte -> ((bit * bit * bit * bit) * (bit * bit * bit * bit))
    2021val mk_word: byte -> byte -> word
    2122val from_word: word -> byte * byte
     
    2324val from_word11: word11 -> bit * bit * bit * byte
    2425
    25 val to_bits: 'a vect -> bit list
    2626val get_bit: 'a vect -> int -> bit option
    2727val set_bit: 'a vect -> int -> bit -> 'a vect option
  • Deliverables/D4.1/physical.ml

    r92 r97  
    1414
    1515let byte7_of_byte b =
    16   let bits = to_bits b in
    17     match bits with
    18       [false;b1;b2;b3;b4;b5;b6;b7] -> mk_byte7 b1 b2 b3 (mk_nibble b4 b5 b6 b7)
     16  let n1,n2 = from_byte b in
     17    match from_nibble n1 with
     18      (false,b1,b2,b3) -> mk_byte7 b1 b2 b3 n2
    1919    | _ -> raise Byte7_conversion
    2020
     
    6161;;
    6262
    63 let byte_of_byte7 ([b1;b2;b3]::n) =
    64         [false;b1;b2;b3]::n
     63let byte_of_byte7 =
     64 function
     65    ([b1;b2;b3]::n) -> [false;b1;b2;b3]::n
     66  | _ -> assert false
    6567;;
Note: See TracChangeset for help on using the changeset viewer.