/*
    MartyPC
    https://github.com/dbalsom/martypc

    Copyright 2022-2024 Daniel Balsom

    Permission is hereby granted, free of charge, to any person obtaining a
    copy of this software and associated documentation files (the “Software”),
    to deal in the Software without restriction, including without limitation
    the rights to use, copy, modify, merge, publish, distribute, sublicense,
    and/or sell copies of the Software, and to permit persons to whom the
    Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    DEALINGS IN THE SOFTWARE.

    ---------------------------------------------------------------------------

    cpu_808x::microcode.rs

    Provides disassembly of each line of the 8088 microcode.
    Used for debug printing when cycle tracing is enabled.

    Microcode disassembly by reenigne:
    https://www.reenigne.org/blog/8086-microcode-disassembled/

*/

pub const MC_NONE: u16 = 0x200;
pub const MC_JUMP: u16 = 0x201;
pub const MC_RTN: u16 = 0x202;
pub const MC_CORR: u16 = 0x203;

pub const NX: u8 = 1;
pub const RNI: u8 = 2;

pub const MICROCODE_NUL: &str = "                |                 ";

pub const MICROCODE_SRC_8088: &[&str] = &[
    "XA   -> tmpb    | none  WB,NX     ",
    "tmpb -> M       | none  RNI       ",
    "                | W,RNI DD,P0     ",
    "IJ   -> tmpa    | UNC   EAOFFSET  ",
    "IND  -> R       | none  RNI       ",
    "                |                 ",
    "                |                 ",
    "                |                 ",
    "M    -> tmpa    | XI    tmpa      ",
    "R    -> tmpb    | none  WB,NX     ",
    "SIGMA-> M       | none  RNI      F",
    "                | W,RNI DD,P0     ",
    "Q    -> tmpbL   | L8    2         ",
    "Q    -> tmpbH   |                 ",
    "M    -> tmpa    | XI    tmpa, NX  ",
    "SIGMA-> M       | none  RNI      F",
    "                | W,RNI DD,P0     ",
    "                |                 ",
    "                |                 ",
    "                |                 ",
    "Q    -> tmpbL   | L8    2         ",
    "Q    -> tmpbH   |                 ",
    "tmpb -> M       | none  RNI       ",
    "                | W,RNI DD,P0     ",
    "Q    -> tmpbL   | L8    2         ",
    "Q    -> tmpbH   |                 ",
    "M    -> tmpa    | XI    tmpa, NX  ",
    "SIGMA-> M       | none  RNI      F",
    "Q    -> tmpbL   | L8    2         ",
    "Q    -> tmpbH   |                 ",
    "tmpb -> M       | none  RNI       ",
    "IK   -> tmpa    | UNC   EAOFFSET  ",
    "M    -> tmpb    | XI    tmpb, NX  ",
    "SIGMA-> M       | none  RNI      F",
    "                | W,RNI DD,P0     ",
    "MP   -> tmpa    | UNC   EAOFFSET  ",
    "SP   -> tmpa    | DEC2  tmpa      ",
    "SIGMA-> IND     |                 ",
    "SIGMA-> SP      |                 ",
    "M    -> OPR     | W,RNI DS,P0     ",
    "SP   -> tmpa    | DEC2  tmpa      ",
    "SIGMA-> IND     |                 ",
    "SIGMA-> SP      |                 ",
    "M    -> OPR     | W,RNI DS,P0     ",
    "SP   -> tmpa    | DEC2  tmpa      ",
    "SIGMA-> IND     |                 ",
    "SIGMA-> SP      |                 ",
    "R    -> OPR     | W,RNI DS,P0     ",
    "SP   -> tmpa    | DEC2  tmpa      ",
    "SIGMA-> IND     |                 ",
    "SIGMA-> SP      |                 ",
    "F    -> OPR     | W,RNI DS,P0     ",
    "SP   -> IND     | R     DS,P2     ",
    "IND  -> SP      | none  NWB,NX    ",
    "OPR  -> M       | none  RNI       ",
    "HL   -> tmpa    | UNC   EAOFFSET  ",
    "SP   -> IND     | R     DS,P2     ",
    "IND  -> SP      | none  NWB,NX    ",
    "OPR  -> R       | none  RNI       ",
    "                |                 ",
    "SP   -> IND     | R     DS,P2     ",
    "IND  -> SP      | none  NWB,NX    ",
    "OPR  -> F       | none  RNI       ",
    "                |                 ",
    "IND  -> tmpa    |                 ",
    "SP   -> IND     | R     DS,P2     ",
    "IND  -> SP      |                 ",
    "tmpa -> IND     | none  WB,NX     ",
    "OPR  -> M       | none  RNI       ",
    "                | W,RNI DD,P0     ",
    "                |                 ",
    "                |                 ",
    "                |                 ",
    "                |                 ",
    "                |                 ",
    "                |                 ",
    "M    -> tmpb    | XI    tmpb, NX  ",
    "SIGMA-> M       | none  RNI       ",
    "                | W,RNI DD,P0     ",
    "                |                 ",
    "M    -> tmpb    | XI    tmpb, NX  ",
    "SIGMA-> M       | none  RNI      F",
    "                | W,RNI DD,P0     ",
    "                |                 ",
    "XA   -> tmpbL   | none  NWB,NX    ",
    "tmpb -> XA      | none  RNI       ",
    "                |                 ",
    "                |                 ",
    "XA   -> tmpb    | LRCY  tmpb      ",
    "SIGMA-> tmpb    | RRCY  tmpb      ",
    "                | CY    5         ",
    "ZERO -> DE      | none  NWB,NX    ",
    "SIGMA-> tmpb    | none  RNI       ",
    "ONES -> DE      | none  NWB,NX    ",
    "SIGMA-> tmpb    | none  RNI       ",
    "                |                 ",
    "Q    -> tmpbL   |                 ",
    "Q    -> tmpbH   |                 ",
    "tmpb -> IND     | R     DD,P0     ",
    "OPR  -> M       | none  RNI       ",
    "Q    -> tmpbL   |                 ",
    "Q    -> tmpbH   |                 ",
    "tmpb -> IND     |                 ",
    "M    -> OPR     | W,RNI DD,P0     ",
    "IND  -> tmpc    | INC2  tmpc      ",
    "SIGMA-> IND     | R     DD,P0     ",
    "OPR  -> tmpa    | DEC2  tmpc      ",
    "SP   -> tmpc    | none  SUSP      ",
    "SIGMA-> IND     | none  CORR      ",
    "RC   -> OPR     | w     DS,M2     ",
    "tmpa -> RC      | PASS  tmpc      ",
    "PC   -> OPR     | UNC   NEARCALL  ",
    "Q    -> tmpbL   |                 ",
    "Q    -> tmpbH   |                 ",
    "Q    -> tmpaL   | DEC2  tmpc      ",
    "Q    -> tmpaH   | UNC   FARCALL   ",
    "M    -> tmpb    | none  SUSP      ",
    "SP   -> IND     | none  CORR      ",
    "PC   -> OPR     | DEC2  tmpc      ",
    "tmpb -> PC      | FLUSH none      ",
    "IND  -> tmpc    |                 ",
    "SIGMA-> IND     |                 ",
    "SIGMA-> SP      | W,RNI DS,P0     ",
    "                |                 ",
    "Q    -> tmpbL   |                 ",
    "Q    -> tmpbH   | DEC2  tmpc      ",
    "SP   -> tmpc    | none  SUSP      ",
    "SIGMA-> IND     | none  CORR      ",
    "PC   -> tmpa    | ADD   tmpa      ",
    "SIGMA-> PC      | FLUSH none      ",
    "IND  -> SP      | UNC   7         ",
    "tmpa -> OPR     | W,RNI DS,P0     ",
    "M    -> tmpb    |                 ",
    "XA   -> M       | none  NWB,NX    ",
    "tmpb -> XA      | none  RNI       ",
    "                |                 ",
    "M    -> tmpb    | XI    tmpb, NX  ",
    "SIGMA-> M       | none  RNI      F",
    "                | W,RNI DD,P0     ",
    "                |                 ",
    "ZERO -> tmpa    |                 ",
    "BC   -> tmpaL   | PASS  tmpa      ",
    "M    -> tmpb    | UNC   4         ",
    "SIGMA-> tmpb    | DEC   tmpa     F",
    "SIGMA-> tmpa    | XI    tmpb      ",
    "                | NZ    3         ",
    "tmpb -> M       | none  RNI       ",
    "                | W,RNI DD,P0     ",
    "M    -> tmpa    | AND   tmpa      ",
    "R    -> tmpb    | none  NWB,NX    ",
    "SIGMA-> no dest | none  RNI      F",
    "                |                 ",
    "Q    -> tmpbL   | L8    2         ",
    "Q    -> tmpbH   |                 ",
    "M    -> tmpa    | AND   tmpa, NX  ",
    "SIGMA-> no dest | none  RNI      F",
    "Q    -> tmpbL   | L8    2         ",
    "Q    -> tmpbH   |                 ",
    "XA   -> tmpa    | AND   tmpa, NX  ",
    "SIGMA-> no dest | none  RNI      F",
    "                | CY    2         ",
    "ZERO -> A       | none  RNI       ",
    "ONES -> A       | none  RNI       ",
    "                |                 ",
    "R    -> tmpa    |                 ",
    "M    -> tmpb    |                 ",
    "tmpb -> R       | none  WB,NX     ",
    "tmpa -> M       | none  RNI       ",
    "                | W,RNI DD,P0     ",
    "                |                 ",
    "                |                 ",
    "                |                 ",
    "Q    -> tmpbL   |                 ",
    "ZERO -> tmpbH   | PASS  tmpb      ",
    "SIGMA-> IND     | R     D0,P0     ",
    "OPR  -> M       | none  RNI       ",
    "Q    -> tmpbL   |                 ",
    "ZERO -> tmpbH   | PASS  tmpb      ",
    "SIGMA-> IND     |                 ",
    "XA   -> OPR     | W,RNI D0,P0     ",
    "DE   -> IND     | R     D0,P0     ",
    "OPR  -> M       | none  RNI       ",
    "                |                 ",
    "                |                 ",
    "DE   -> IND     |                 ",
    "XA   -> OPR     | W,RNI D0,P0     ",
    "                |                 ",
    "                |                 ",
    "SP   -> IND     | R     DS,P2     ",
    "                | none  SUSP      ",
    "OPR  -> PC      | FLUSH none      ",
    "IND  -> SP      | none  RNI       ",
    "                | UNC   FARRET    ",
    "IND  -> SP      | none  RNI       ",
    "SP   -> IND     | R     DS,P2     ",
    "                | none  SUSP      ",
    "OPR  -> PC      | X0    6         ",
    "                | FLUSH RTN       ",
    "                | R     DS,P2     ",
    "OPR  -> RC      | FLUSH RTN       ",
    "                | UNC   FARRET    ",
    "                | R     DS,P2     ",
    "OPR  -> F       |                 ",
    "IND  -> SP      | none  RNI       ",
    "Q    -> tmpaL   | ADD   tmpa      ",
    "Q    -> tmpaH   | UNC   FARRET    ",
    "IND  -> tmpb    |                 ",
    "SIGMA-> SP      | none  RNI       ",
    "Q    -> tmpbL   | L8    2         ",
    "Q    -> tmpbH   |                 ",
    "                | none  SUSP      ",
    "                | none  CORR      ",
    "PC   -> tmpa    | ADD   tmpa      ",
    "SIGMA-> PC      | FLUSH RNI       ",
    "                |                 ",
    "                |                 ",
    "                | none  SUSP      ",
    "M    -> PC      | FLUSH RNI       ",
    "                |                 ",
    "                |                 ",
    "IND  -> tmpc    | INC2  tmpc      ",
    "SIGMA-> IND     | none  SUSP      ",
    "tmpb -> PC      | R     DD,P0     ",
    "OPR  -> RC      | FLUSH RNI       ",
    "Q    -> tmpbL   |                 ",
    "Q    -> tmpbH   |                 ",
    "Q    -> tmpaL   |                 ",
    "Q    -> tmpaH   |                 ",
    "                | none  SUSP      ",
    "tmpb -> PC      |                 ",
    "tmpa -> RC      | FLUSH RNI       ",
    "                |                 ",
    "Q    -> tmpbL   |                 ",
    "                | XC    RELJMP    ",
    "                | none  RNI       ",
    "                |                 ",
    "R    -> M       | none  RNI       ",
    "                | W,RNI DD,P0     ",
    "                |                 ",
    "                |                 ",
    "OPR  -> R       |                 ",
    "IND  -> tmpc    | INC2  tmpc      ",
    "SIGMA-> IND     | R     DD,P0     ",
    "OPR  -> RA      | none  RNI       ",
    "OPR  -> R       |                 ",
    "IND  -> tmpc    | INC2  tmpc      ",
    "SIGMA-> IND     | R     DD,P0     ",
    "OPR  -> RD      | none  RNI       ",
    "                | TEST  3         ",
    "                | WAIT  none      ",
    "                | none  RNI       ",
    "                | INT   5         ",
    "                | UNC   0         ",
    "                | none  SUSP      ",
    "                | none  CORR      ",
    "PC   -> tmpc    | DEC   tmpc      ",
    "                |                 ",
    "F    -> tmpa    |                 ",
    "X    -> tmpaL   | none  NWB,NX    ",
    "tmpa -> F       | none  RNI       ",
    "                | none  NWB,NX    ",
    "F    -> X       | none  RNI       ",
    "                |                 ",
    "                |                 ",
    "                | none  RNI       ",
    "                |                 ",
    "                |                 ",
    "                |                 ",
    "ZERO -> tmpa    |                 ",
    "XA   -> tmpaL   |                 ",
    "HL   -> tmpb    | ADD   tmpa      ",
    "SIGMA-> IND     | R     DD,P0     ",
    "OPR  -> A       | none  RNI       ",
    "                |                 ",
    "BC   -> tmpc    | PASS  tmpc      ",
    "SIGMA-> no dest | DEC   tmpc      ",
    "                | NZ    10        ",
    "                | none  RNI       ",
    "                | none  RTN       ",
    "                |                 ",
    "tmpc -> BC      | none  SUSP      ",
    "                | none  CORR      ",
    "PC   -> tmpb    | DEC2  tmpb      ",
    "SIGMA-> PC      | FLUSH RNI       ",
    "IK   -> IND     | F1    RPTS      ",
    "M    -> OPR     | w     DA,BL     ",
    "IND  -> IK      | NF1   5         ",
    "SIGMA-> tmpc    | INT   RPTI      ",
    "                | F1    RPTS      ",
    "M    -> tmpa    | X0    5         ",
    "IJ   -> IND     | R     DD,BL     ",
    "IND  -> IJ      |                 ",
    "OPR  -> tmpa    |                 ",
    "IK   -> IND     | R     DA,BL     ",
    "OPR  -> tmpb    | SUBT  tmpa      ",
    "SIGMA-> no dest | DEC   tmpc     F",
    "IND  -> IK      | NF1   12        ",
    "SIGMA-> BC      | F1ZZ  12        ",
    "SIGMA-> tmpc    | INT   RPTI      ",
    "                | NZ    1         ",
    "                | F1    RPTS      ",
    "IJ   -> IND     | R     DD,BL     ",
    "IND  -> IJ      | X0    8         ",
    "IK   -> IND     | w     DA,BL     ",
    "IND  -> IK      | NF1   7         ",
    "SIGMA-> tmpc    | INT   RPTI      ",
    "tmpc -> BC      | NZ    1         ",
    "                | none  RNI       ",
    "BC   -> tmpc    | PASS  tmpc      ",
    "SIGMA-> no dest |                 ",
    "Q    -> tmpbL   | NZ    4         ",
    "                | UNC   RELJMP    ",
    "BC   -> tmpc    | DEC   tmpc      ",
    "SIGMA-> BC      |                 ",
    "Q    -> tmpbL   | F1ZZ  4         ",
    "                | NZ    RELJMP    ",
    "                | none  RNI       ",
    "                |                 ",
    "                |                 ",
    "                |                 ",
    "BC   -> tmpc    | DEC   tmpc      ",
    "SIGMA-> BC      |                 ",
    "Q    -> tmpbL   | NZ    RELJMP    ",
    "                | none  RNI       ",
    "A    -> tmpaL   | XI    tmpa      ",
    "ONES -> tmpb    |                 ",
    "SIGMA-> A       | ADD   tmpa, NX F",
    "                | none  RNI       ",
    "A    -> tmpaL   | XI    tmpa      ",
    "ONES -> tmpb    |                 ",
    "SIGMA-> A       | DEC   tmpb     F",
    "                | X0    5         ",
    "                | INC   tmpb      ",
    "X    -> tmpb    | NCY   7         ",
    "SIGMA-> X       | none  RNI       ",
    "                | none  RNI       ",
    "A    -> tmpc    | LRCY  tmpc      ",
    "M    -> tmpb    | X0    PREIMUL   ",
    "                | UNC   CORX      ",
    "                | F1    NEGATE    ",
    "                | X0    IMULCOF   ",
    "tmpc -> A       | X0    7         ",
    "                | UNC   MULCOF    ",
    "tmpa -> X       | none  RNI       ",
    "XA   -> tmpc    | LRCY  tmpc      ",
    "M    -> tmpb    | X0    PREIMUL   ",
    "                | UNC   CORX      ",
    "                | F1    NEGATE    ",
    "                | X0    IMULCOF   ",
    "tmpc -> XA      | X0    7         ",
    "                | UNC   MULCOF    ",
    "tmpa -> DE      | none  RNI       ",
    "X    -> tmpa    |                 ",
    "A    -> tmpc    | LRCY  tmpa      ",
    "M    -> tmpb    | X0    PREIDIV   ",
    "                | UNC   CORD      ",
    "                | COM1  tmpc      ",
    "X    -> tmpb    | X0    POSTIDIV  ",
    "SIGMA-> A       | none  NWB,NX    ",
    "tmpa -> X       | none  RNI       ",
    "DE   -> tmpa    |                 ",
    "XA   -> tmpc    | LRCY  tmpa      ",
    "M    -> tmpb    | X0    PREIDIV   ",
    "                | UNC   CORD      ",
    "                | COM1  tmpc      ",
    "DE   -> tmpb    | X0    POSTIDIV  ",
    "SIGMA-> XA      | none  NWB,NX    ",
    "tmpa -> DE      | none  RNI       ",
    "Q    -> tmpc    |                 ",
    "X    -> tmpb    | UNC   CORX      ",
    "A    -> tmpb    | ADD   tmpc      ",
    "ZERO -> X       | UNC   AAEND     ",
    "Q    -> tmpb    |                 ",
    "ZERO -> tmpa    |                 ",
    "A    -> tmpc    | UNC   CORD      ",
    "                | COM1  tmpc      ",
    "SIGMA-> X       | PASS  tmpa, NX  ",
    "SIGMA-> A       | none  RNI      F",
    "                |                 ",
    "                |                 ",
    "M    -> tmpb    | XI    tmpb, NX  ",
    "SIGMA-> M       | none  RNI      F",
    "                |                 ",
    "ZERO -> tmpa    | RRCY  tmpc      ",
    "SIGMA-> tmpc    | MAXC  none      ",
    "                | NCY   8         ",
    "                | ADD   tmpa      ",
    "SIGMA-> tmpa    |                F",
    "                | RRCY  tmpa      ",
    "SIGMA-> tmpa    | RRCY  tmpc      ",
    "SIGMA-> tmpc    | NCZ   5         ",
    "                | none  RTN       ",
    "                | SUBT  tmpa      ",
    "SIGMA-> no dest | MAXC  none     F",
    "                | NCY   INT0      ",
    "                | LRCY  tmpc      ",
    "SIGMA-> tmpc    | LRCY  tmpa      ",
    "SIGMA-> tmpa    | SUBT  tmpa      ",
    "                | CY    13        ",
    "SIGMA-> no dest |                F",
    "                | NCY   14        ",
    "                | NCZ   3         ",
    "                | LRCY  tmpc      ",
    "SIGMA-> tmpc    |                 ",
    "SIGMA-> no dest | none  RTN       ",
    "                | RCY   none      ",
    "SIGMA-> tmpa    | NCZ   3         ",
    "                | UNC   10        ",
    "CR   -> tmpbL   | UNC   6         ",
    "CR   -> tmpbL   | UNC   6         ",
    "XA   -> tmpc    | IRQ   D0,P0     ",
    "OPR  -> XA      | none  SUSP      ",
    "X    -> tmpbL   |                 ",
    "tmpc -> XA      |                 ",
    "ZERO -> tmpbH   | ADD   tmpb      ",
    "SIGMA-> tmpb    |                 ",
    "SIGMA-> IND     | R     D0,P2     ",
    "OPR  -> tmpb    | DEC2  tmpc      ",
    "SP   -> tmpc    | R     D0,P0     ",
    "OPR  -> tmpa    | none  SUSP      ",
    "F    -> OPR     | CITF  none      ",
    "SIGMA-> IND     | w     DS,P0     ",
    "IND  -> tmpc    | UNC   FARCALL2  ",
    "CR   -> tmpbL   | UNC   6         ",
    "Q    -> tmpbL   | UNC   INTR      ",
    "tmpb -> OPR     | UNC   INTR      ",
    "                |                 ",
    "                |                 ",
    "                |                 ",
    "                | OF    3         ",
    "                | none  RNI       ",
    "CR   -> tmpbL   | UNC   INTR      ",
    "                | UNC   2         ",
    "                |                 ",
    "CR   -> tmpbL   | UNC   INTR      ",
    "                |                 ",
    "SIGMA-> no dest |                 ",
    "                | NCY   7         ",
    "                | NEG   tmpc      ",
    "SIGMA-> tmpc    | COM1  tmpa     F",
    "                | CY    6         ",
    "                | NEG   tmpa      ",
    "SIGMA-> tmpa    | CF1   none      ",
    "                | LRCY  tmpb      ",
    "SIGMA-> no dest | NEG   tmpb      ",
    "                | NCY   11        ",
    "SIGMA-> tmpb    | CF1   RTN       ",
    "                | none  RTN       ",
    "SIGMA-> no dest | NEG   tmpc      ",
    "                | NCY   7         ",
    "SIGMA-> tmpc    | CF1   none      ",
    "                | UNC   7         ",
    "                | NCY   INT0      ",
    "                | LRCY  tmpb      ",
    "SIGMA-> no dest | NEG   tmpa      ",
    "                | NCY   5         ",
    "SIGMA-> tmpa    |                 ",
    "                | INC   tmpc      ",
    "                | F1    8         ",
    "                | COM1  tmpc      ",
    "                | CCOF  RTN       ",
    "ZERO -> tmpb    | LRCY  tmpc      ",
    "SIGMA-> no dest | ADC   tmpa      ",
    "SIGMA-> no dest |       F        F",
    "                | Z     8         ",
    "                | SCOF  RTN       ",
    "                | PASS  tmpa      ",
    "SIGMA-> no dest | UNC   12       F",
    "HL   -> tmpa    |                 ",
    "IJ   -> tmpb    |                 ",
    "SIGMA-> tmpa    | UNC   EAOFFSET  ",
    "MP   -> tmpa    |                 ",
    "IK   -> tmpb    |                 ",
    "SIGMA-> tmpa    | UNC   EAOFFSET  ",
    "HL   -> tmpa    | UNC   4         ",
    "MP   -> tmpa    | UNC   1         ",
    "Q    -> tmpaL   |                 ",
    "Q    -> tmpaH   | UNC   EAFINISH  ",
    "Q    -> tmpbL   | MOD1  12        ",
    "Q    -> tmpbH   |                 ",
    "SIGMA-> tmpa    | UNC   EAFINISH  ",
    "tmpa -> IND     | R     DD,P0     ",
    "OPR  -> tmpb    | none  RTN       ",
    "tmpa -> IND     | none  RTN       ",
    "ZERO -> RD      | none  SUSP      ",
    "ONES -> RC      |                 ",
    "ZERO -> PC      | FLUSH none      ",
    "ZERO -> F       |                 ",
    "ZERO -> RA      |                 ",
    "ZERO -> RS      | none  RNI       ",
    "                |                 ",
    "                |                 ",
    "SIGMA-> PC      | FLUSH RNI       ",
    "                |                 ",
    "                |                 ",
    "                |                 ",
    "tmpc -> BC      | NZ    1         ",
    "                | none  RNI       ",
    "                |                 ",
    "                |                 ",
    "                | none  RNI       ",
    "                |                 ",
    "                |                 ",
    "                |                 ",
    "OPR  -> M       | F1    5         ",
    "                | none  RNI       ",
    "IND  -> tmpaL   | LRCY  tmpc     F",
    "                |                 ",
    "                | none  RNI       ",
    "                |                 ",
    "A    -> tmpa    | INT   FARCALL2  ",
    "[  5]-> [ a]    | UNC   INTR     F",
];

#[allow(dead_code)]
pub const MICROCODE_FLAGS_8088: &[u8] = &[
    NX, RNI, RNI, 0, RNI, 0, 0, 0, 0, NX, RNI, RNI, 0, 0, NX, RNI, RNI, 0, 0, 0, 0, 0, RNI, RNI, 0, 0, NX, RNI, 0, 0,
    RNI, 0, NX, RNI, RNI, 0, 0, 0, 0, RNI, 0, 0, 0, RNI, 0, 0, 0, RNI, 0, 0, 0, RNI, 0, NX, RNI, 0, 0, NX, RNI, 0, 0,
    NX, RNI, 0, 0, 0, 0, NX, RNI, RNI, 0, 0, 0, 0, 0, 0, NX, RNI, RNI, 0, NX, RNI, RNI, 0, NX, RNI, 0, 0, 0, 0, 0, NX,
    RNI, NX, RNI, 0, 0, 0, 0, RNI, 0, 0, 0, RNI, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, RNI, 0, 0, 0, 0,
    0, 0, 0, 0, RNI, 0, NX, RNI, 0, NX, RNI, RNI, 0, 0, 0, 0, 0, 0, 0, RNI, RNI, 0, NX, RNI, 0, 0, 0, NX, RNI, 0, 0,
    NX, RNI, 0, RNI, RNI, 0, 0, 0, NX, RNI, RNI, 0, 0, 0, 0, 0, 0, RNI, 0, 0, 0, RNI, 0, RNI, 0, 0, 0, RNI, 0, 0, 0, 0,
    0, RNI, 0, RNI, 0, 0, 0, 0, 0, 0, 0, 0, 0, RNI, 0, 0, 0, RNI, 0, 0, 0, 0, 0, RNI, 0, 0, 0, RNI, 0, 0, 0, 0, 0, RNI,
    0, 0, 0, 0, 0, 0, RNI, 0, 0, 0, RNI, 0, RNI, RNI, 0, 0, 0, 0, 0, RNI, 0, 0, 0, RNI, 0, 0, RNI, 0, 0, 0, 0, 0, 0, 0,
    NX, RNI, NX, RNI, 0, 0, RNI, 0, 0, 0, 0, 0, 0, 0, RNI, 0, 0, 0, 0, RNI, 0, 0, 0, 0, 0, RNI, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, RNI, 0, 0, 0, 0, 0, 0, 0, 0, RNI, 0, 0, 0, 0, 0, 0, RNI, 0, 0, NX,
    RNI, 0, 0, 0, 0, 0, 0, RNI, RNI, 0, 0, 0, 0, 0, 0, 0, RNI, 0, 0, 0, 0, 0, 0, 0, RNI, 0, 0, 0, 0, 0, 0, NX, RNI, 0,
    0, 0, 0, 0, 0, NX, RNI, 0, 0, 0, 0, 0, 0, 0, 0, NX, RNI, 0, 0, NX, RNI, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, RNI, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, RNI, 0, 0, RNI, 0, 0, 0, 0, RNI, 0, 0, RNI, 0, 0, 0, 0, RNI, 0,
    0, RNI, 0, 0, 0, 0, // MC_NONE: u16 = 0x200;
    0, // MC_JUMP: u16 = 0x201;
    0, // MC_RTN:  u16 = 0x202;
    0, // MC_CORR: u16 = 0x203;
];

pub const MICROCODE_ADDRESS_8088: &[u16; 256] = &[
    0x008, 0x008, 0x008, 0x008, 0x018, 0x018, 0x02c, 0x038, 0x008, 0x008, 0x008, 0x008, 0x018, 0x018, 0x02c, 0x038,
    0x008, 0x008, 0x008, 0x008, 0x018, 0x018, 0x02c, 0x038, 0x008, 0x008, 0x008, 0x008, 0x018, 0x018, 0x02c, 0x038,
    0x008, 0x008, 0x008, 0x008, 0x018, 0x018, MC_NONE, 0x144, 0x008, 0x008, 0x008, 0x008, 0x018, 0x018, MC_NONE, 0x144,
    0x008, 0x008, 0x008, 0x008, 0x018, 0x018, MC_NONE, 0x148, 0x008, 0x008, 0x008, 0x008, 0x018, 0x018, MC_NONE, 0x148,
    0x17c, 0x17c, 0x17c, 0x17c, 0x17c, 0x17c, 0x17c, 0x17c, 0x17c, 0x17c, 0x17c, 0x17c, 0x17c, 0x17c, 0x17c, 0x17c,
    0x028, 0x028, 0x028, 0x028, 0x028, 0x028, 0x028, 0x028, 0x034, 0x034, 0x034, 0x034, 0x034, 0x034, 0x034, 0x034,
    0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8,
    0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8, 0x0e8,
    0x00c, 0x00c, 0x00c, 0x00c, 0x094, 0x094, 0x0a4, 0x0a4, 0x000, 0x000, 0x000, 0x000, 0x0ec, 0x004, 0x0ec, 0x040,
    0x084, 0x084, 0x084, 0x084, 0x084, 0x084, 0x084, 0x084, 0x054, 0x058, 0x070, 0x0f8, 0x030, 0x03c, 0x100, 0x104,
    0x060, 0x060, 0x064, 0x064, 0x12c, 0x12c, 0x120, 0x120, 0x09C, 0x09C, 0x11c, 0x11c, 0x12c, 0x12c, 0x120, 0x120,
    0x01c, 0x01c, 0x01c, 0x01c, 0x01c, 0x01c, 0x01c, 0x01c, 0x01c, 0x01c, 0x01c, 0x01c, 0x01c, 0x01c, 0x01c, 0x01c,
    0x0cc, 0x0bc, 0x0cc, 0x0bc, 0x0f0, 0x0f4, 0x014, 0x014, 0x0cc, 0x0c0, 0x0cc, 0x0c0, 0x1b0, 0x1a8, 0x1ac, 0x0c8,
    0x088, 0x088, 0x08c, 0x08c, 0x174, 0x170, 0x0a0, 0x10c, 0x108, 0x108, 0x108, 0x108, 0x108, 0x108, 0x108, 0x108,
    0x138, 0x138, 0x140, 0x134, 0x0ac, 0x0ac, 0x0b0, 0x0b0, 0x07c, 0x0d0, 0x0e0, 0x0d0, 0x0b4, 0x0b4, 0x0b8, 0x0b8,
    MC_NONE, MC_NONE, MC_NONE, MC_NONE, MC_NONE, MC_NONE, 0x098, 0x098, MC_NONE, MC_NONE, MC_NONE, MC_NONE, MC_NONE,
    MC_NONE, 0x020, 0x020,
];
