Changeset 84


Ignore:
Timestamp:
Sep 17, 2010, 10:44:41 AM (9 years ago)
Author:
mulligan
Message:

Lots of work on tidying up code.

Location:
Deliverables/D4.1
Files:
4 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D4.1/Bit.ml

    r83 r84  
    88module type BIT =
    99sig
    10   type bit
     10  type bit = bool (* DPM: Make abstract? *)
    1111
    1212  val from_bool: bool -> bit
  • Deliverables/D4.1/Byte7.ml

    r63 r84  
    77(*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*)
    88
     9open Bit;;
     10open Nibble;;
     11
    912module type BYTE7 =
    1013sig
     
    1417end;;
    1518
    16 module Byte7(Bit: BIT,
    17              Nibble: NIBBLE)
     19module Byte7Functor(Bit: BIT)
     20                   (Nibble: NIBBLE
     21                      with type bit = Bit.bit) : BYTE7
    1822  with type bit    = Bit.bit
    1923  and  type nibble = Nibble.nibble =
     
    2327  type byte7 = (bit * bit * bit * nibble)
    2428end;;
     29
     30module Byte7 = Byte7Functor (Bit) (Nibble);;
  • Deliverables/D4.1/Pretty.ml

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

    r83 r84  
    1616  type nibble
    1717  type byte
    18   type word
     18  type word = byte * byte
    1919end;;
    2020
    21 module Word(Bit: BIT)
    22            (Nibble: NIBBLE with type bit = Bit.bit)
    23            (Byte: BYTE with type bit = Bit.bit and type nibble = Nibble.nibble): WORD
     21module WordFunctor(Bit: BIT)
     22                  (Nibble: NIBBLE
     23                     with type bit    = Bit.bit)
     24                  (Byte: BYTE
     25                     with type bit    = Bit.bit
     26                     and  type nibble = Nibble.nibble): WORD
    2427  with type bit    = Bit.bit
    2528  and  type nibble = Nibble.nibble
     
    3134  type word = (byte * byte)
    3235end;;
     36
     37module Word = WordFunctor(Bit) (Nibble) (Byte);;
Note: See TracChangeset for help on using the changeset viewer.