'''
Instruction set

The final and fixed opcodes of all instructions
'''

from . import misc
from . import arithmetic
from . import data_transfer
from . import control_flow
from . import jump


INSTRUCTION_SET = [
    # misc
    # (0x00, INVALID),
    (0x01, misc.NOP),
    (0x02, misc.HLT),
    (0x03, misc.SHUTDOWN),
    (0x04, misc.PRINT),
    (0x05, misc.PRINTCHAR),
    (0x06, misc.SETTMR),
    # unsigned arithmetic
    (0x10, arithmetic.ADD),
    (0x11, arithmetic.SUB),
    (0x12, arithmetic.MUL),
    (0x13, arithmetic.DIV),
    (0x14, arithmetic.MOD),
    (0x15, arithmetic.INC),
    (0x16, arithmetic.DEC),
    # signed arithmetic
    (0x20, arithmetic.IADD),
    (0x21, arithmetic.ISUB),
    (0x22, arithmetic.IMUL),
    (0x23, arithmetic.IDIV),
    (0x24, arithmetic.IMOD),
    (0x25, arithmetic.IINC),
    (0x26, arithmetic.IDEC),
    (0x27, arithmetic.NEG),
    # logic
    # (0x30, ),
    # (0x31, ),
    # (0x32, ),
    # (0x33, ),
    # (0x34, ),
    # (0x35, ),
    # (0x36, ),
    # (0x37, ),
    # (0x38, ),
    # (0x39, ),
    # (0x3A, ),
    # (0x3B, ),
    # (0x3C, ),
    # (0x3D, ),
    # (0x3E, ),
    # (0x3F, ),
    # shift & rotate
    # (0x40, ),
    # (0x41, ),
    # (0x42, ),
    # (0x43, ),
    # (0x44, ),
    # (0x45, ),
    # (0x46, ),
    # (0x47, ),
    # (0x48, ),
    # (0x49, ),
    # (0x4A, ),
    # (0x4B, ),
    # (0x4C, ),
    # (0x4D, ),
    # (0x4E, ),
    # (0x4F, ),
    # data transfer
    (0x50, data_transfer.MOV),
    # (0x51, data_transfer.XCHG),
    (0x52, data_transfer.PUSH),
    (0x53, data_transfer.POP),
    (0x54, data_transfer.PUSHF),
    (0x55, data_transfer.POPF),
    # (0x56, data_transfer.PUSHA),
    # (0x57, data_transfer.POPA),
    (0x58, data_transfer.IN),
    (0x59, data_transfer.OUT),
    # string
    # (0x60, ),
    # (0x61, ),
    # (0x62, ),
    # (0x63, ),
    # (0x64, ),
    # (0x65, ),
    # (0x66, ),
    # (0x67, ),
    # (0x68, ),
    # (0x69, ),
    # (0x6A, ),
    # (0x6B, ),
    # (0x6C, ),
    # (0x6D, ),
    # (0x6E, ),
    # (0x6F, ),
    # loop
    # (0x70, ),
    # (0x71, ),
    # (0x72, ),
    # (0x73, ),
    # (0x74, ),
    # (0x75, ),
    # (0x76, ),
    # (0x77, ),
    # (0x78, ),
    # (0x79, ),
    # (0x7A, ),
    # (0x7B, ),
    # (0x7C, ),
    # (0x7D, ),
    # (0x7E, ),
    # (0x7F, ),
    # control flow
    (0x80, control_flow.CALL),
    (0x81, control_flow.RET),
    (0x82, control_flow.ENTER),
    (0x83, control_flow.LVRET),
    (0x84, control_flow.INT),
    (0x85, control_flow.IRET),
    (0x86, control_flow.SETINT),
    (0x87, control_flow.STI),
    (0x88, control_flow.CLI),
    # jump
    (0x90, jump.JMP),
    (0x91, jump.JE),
    (0x92, jump.JNE),
    (0x93, jump.JG),
    (0x94, jump.JGE),
    (0x95, jump.JL),
    (0x96, jump.JLE),
    (0x97, jump.JA),
    (0x98, jump.JAE),
    (0x99, jump.JB),
    (0x9A, jump.JBE),

    # #
    # (0xA0, ),
    # (0xA1, ),
    # (0xA2, ),
    # (0xA3, ),
    # (0xA4, ),
    # (0xA5, ),
    # (0xA6, ),
    # (0xA7, ),
    # (0xA8, ),
    # (0xA9, ),
    # (0xAA, ),
    # (0xAB, ),
    # (0xAC, ),
    # (0xAD, ),
    # (0xAE, ),
    # (0xAF, ),
    # #
    # (0xB0, ),
    # (0xB1, ),
    # (0xB2, ),
    # (0xB3, ),
    # (0xB4, ),
    # (0xB5, ),
    # (0xB6, ),
    # (0xB7, ),
    # (0xB8, ),
    # (0xB9, ),
    # (0xBA, ),
    # (0xBB, ),
    # (0xBC, ),
    # (0xBD, ),
    # (0xBE, ),
    # (0xBF, ),
    # #
    # (0xC0, ),
    # (0xC1, ),
    # (0xC2, ),
    # (0xC3, ),
    # (0xC4, ),
    # (0xC5, ),
    # (0xC6, ),
    # (0xC7, ),
    # (0xC8, ),
    # (0xC9, ),
    # (0xCA, ),
    # (0xCB, ),
    # (0xCC, ),
    # (0xCD, ),
    # (0xCE, ),
    # (0xCF, ),
    # #
    # (0xD0, ),
    # (0xD1, ),
    # (0xD2, ),
    # (0xD3, ),
    # (0xD4, ),
    # (0xD5, ),
    # (0xD6, ),
    # (0xD7, ),
    # (0xD8, ),
    # (0xD9, ),
    # (0xDA, ),
    # (0xDB, ),
    # (0xDC, ),
    # (0xDD, ),
    # (0xDE, ),
    # (0xDF, ),
    # #
    # (0xE0, ),
    # (0xE1, ),
    # (0xE2, ),
    # (0xE3, ),
    # (0xE4, ),
    # (0xE5, ),
    # (0xE6, ),
    # (0xE7, ),
    # (0xE8, ),
    # (0xE9, ),
    # (0xEA, ),
    # (0xEB, ),
    # (0xEC, ),
    # (0xED, ),
    # (0xEE, ),
    # (0xEF, ),
    # #
    # (0xF0, ),
    # (0xF1, ),
    # (0xF2, ),
    # (0xF3, ),
    # (0xF4, ),
    # (0xF5, ),
    # (0xF6, ),
    # (0xF7, ),
    # (0xF8, ),
    # (0xF9, ),
    # (0xFA, ),
    # (0xFB, ),
    # (0xFC, ),
    # (0xFD, ),
    # (0xFE, ),
    # (0xFF, ),
]


INSTRUCTION_GROUPS = [
    ('misc', 'Misc'),
    ('arithmetic', 'Arithmetic'),
    ('data_transfer', 'Data transfer'),
    ('control_flow', 'Control flow'),
    ('jump', 'Jump'),
]
