match= { reg: "(io|sp|ipage|dpage|stackptr|gp[0-3])", imm8: "~?#(0b[0-1]{1,8}|(0x)?[0-9]{1,3})", label: "[A-z][A-z0-9]*", flags: "(INPUT|OVERFLOW|NEGATIVE|CARRY|ZERO)" } instructions = { match: match, registers:[ "io", "stackptr", "dpage", "ipage", "gp0", "gp1", "gp2", "gp3" ], flags:[ "INPUT", "OVERFLOW", "NEGATIVE", "CARRY", "ZERO" ].reverse(), arg_patterns:[ [ { pattern: [ match.reg, match.reg ], mode: 0 }, { pattern: [ match.reg, match.imm8 ], mode: 1 }, ], [ { pattern: [ match.reg ], mode: 0 } ], [ { pattern: [ match.reg ], mode: 1 } ], [ { pattern: [ match.flags, match.reg ], mode: 0 }, { pattern: [ match.flags, match.imm8 ], mode: 1 }, ], [ { pattern: [ match.reg ], mode: 0 }, { pattern: [ match.imm8 ], mode: 1 }, ], [ { pattern: [ ], mode: 0 } ], [ { pattern: [ ], mode: 1 } ] ], opcodes:[ { opcode: 0b0000, mnemonic:"add", patterns: 0, description: "Adds the immediate data, or the contents of the register given as the second operand to the register given as first operand." }, { opcode: 0b0001, mnemonic:"sub", patterns: 0, description: "Subtracts the immediate data, or the contents of the register given as the third operand to the register given as the first operand." }, { opcode:0b0010, mnemonic: "adc", patterns: 0, description: "Adds the two operands plus the carry flag, stores in the first operand register." }, { opcode:0b0011, mnemonic:"subb", patterns:0, description: "Subtracts the second operand plus the carry flag from the first operand." }, { opcode:0b0100, mnemonic:"nand", patterns:0, description:"Performs logical NAND on the two operands; stores in first operand register." }, { opcode:0b0101, mnemonic: "xor", patterns:0, description:"Performs logical XOR on the two operands; stores in first operand register." }, { opcode:0b0110, mnemonic:"sll", patterns:0, description:"Shifts bits in the first operand register left by the amount specified in the second operand." }, { opcode:0b0111, mnemonic:"srl", patterns:0, description:"Shifts bits in the first operand register right by the amount specified in the second operand." }, { opcode:0b1000, mnemonic:"mov", patterns:0, description: "Copies the register or data in the second operand into the first operand register." }, { opcode:0b1001, mnemonic:"ldb", patterns:0, description:"Loads the byte into the first operand register at the address specified in the second operand." }, { opcode:0b1010, mnemonic:"stb", patterns:0, description:"Stores the contents of the first operand register into the address specified in the second operand." }, { opcode:0b1011, mnemonic:"nop", patterns:5, description:"performs no operation." }, { opcode:0b1100, mnemonic:"bflag", patterns:0, description: "Branches to the specified memory address if the specified flag bit is set." }, { opcode:0b1101, mnemonic:"bnoflag", patterns:0, description: "Branches to the specified memory address if the specified flag bit is NOT set." }, { opcode:0b1110, mnemonic:"jmp", patterns:4, description:"Branches unconditionally to the specified memory address." }, { opcode:0b1111, mnemonic:"hlt", patterns:5, description:"Terminates execution." } ] }