<< lib/cpu/SLInstructionSet.sleela SLeeLa Standard Library Definition. Definition: Defines SLInstructionSet — the CPU's instruction set architecture (ISA): the catalog of operations the control unit decodes and executes. This is a RISC-style ISA broad enough to be a lowering target for compiled C, C++, Java, and Sleela: load/store (immediate, register, and indexed addressing), full integer arithmetic/logic, compare, conditional and unconditional branches, a real call/return and stack protocol, I/O, system calls, and halt. It aligns with the canonical SLeeLa VM ISA in lib/vm/InstructionSet.sleela (OP_ADD, OP_JMP, OP_CALL, OP_RET, OP_HALT, ...). The multi-language frontends (SLFrontendC, SLFrontendCpp, SLFrontendJava, SLFrontendSleela) lower to the common IR (SLIR) which emits these opcodes. Each mnemonic has a stable numeric opcode; mnemonic<->code lookup is provided. Family: cpu. Pure Sleela ISA registry. >> #sleela 2.5 material; class SLInstructionSet { < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- > << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader, or catalog can read and (where appropriate) override this record. Values are faithful to the subject's real origin where publicly known. >> String metaVersion = "1.0.0"; int metaId = 10254; String metaAuthor = "Kiro Agent"; String metaDate = "2026-10-16"; String metaCopyright = "SLeeLa project"; String metaTrademark = "none"; String metaCorporation = "none"; < metaOrigin: National | | International | Galactic > String metaOrigin = "International"; String metaBirthDate = "2026-10-06"; < metaScienceRating: maturity/robustness on a 1..10 scale > int metaScienceRating = 9; < metaNationalSchedule: a real, citable instrument or "none" > String metaNationalSchedule = "none"; String getMetaVersion() { return metaVersion; } void setMetaVersion(String v) { metaVersion = v; } int getMetaId() { return metaId; } void setMetaId(int v) { metaId = v; } String getAuthor() { return metaAuthor; } void setAuthor(String v) { metaAuthor = v; } String getDate() { return metaDate; } void setDate(String v) { metaDate = v; } String getCopyright() { return metaCopyright; } void setCopyright(String v) { metaCopyright = v; } String getTrademark() { return metaTrademark; } void setTrademark(String v) { metaTrademark = v; } String getCorporation() { return metaCorporation; } void setCorporation(String v) { metaCorporation = v; } String getOrigin() { return metaOrigin; } void setOrigin(String v) { metaOrigin = v; } String getBirthDate() { return metaBirthDate; } void setBirthDate(String v) { metaBirthDate = v; } int getScienceRating() { return metaScienceRating; } void setScienceRating(int v) { metaScienceRating = v; } String getNationalSchedule() { return metaNationalSchedule; } void setNationalSchedule(String v) { metaNationalSchedule = v; } < --- control / misc --- > static final int NOP = 0; static final int HALT = 1; < --- data movement --- > < rd <- imm (load immediate) > static final int MOV = 2; < rd <- rs (register copy) > static final int MOVR = 3; < rd <- mem[imm] (absolute) > static final int LOAD = 4; < rd <- mem[rs] (register-indirect) > static final int LOADR = 5; < rd <- mem[rs + imm] (indexed / struct field, array) > static final int LOADX = 6; < mem[imm] <- rs (absolute) > static final int STORE = 7; < mem[rd] <- rs (register-indirect) > static final int STORER= 8; < mem[rd + imm] <- rs (indexed) > static final int STOREX= 9; < --- integer arithmetic --- > static final int ADD = 10; static final int SUB = 11; static final int MUL = 12; static final int DIV = 13; static final int MOD = 14; static final int NEG = 15; < --- bitwise / shift --- > static final int AND = 16; static final int OR = 17; static final int XOR = 18; static final int NOT = 19; static final int SHL = 20; static final int SHR = 21; < --- compare + branch --- > static final int CMP = 22; < unconditional > static final int JMP = 23; < branch if zero flag > static final int JZ = 24; < branch if not zero > static final int JNZ = 25; < branch if negative flag (less-than after CMP) > static final int JLT = 26; < branch if not negative (>=) > static final int JGE = 27; < --- call / stack --- > < push return addr; jump to imm > static final int CALL = 28; < pop return addr; jump to it > static final int RET = 29; < push rs > static final int PUSH = 30; < pop into rd > static final int POP = 31; < --- i/o + system --- > < rd <- port[imm] > static final int IN = 32; < port[imm] <- rs > static final int OUT = 33; static final int SYSCALL = 34; < software interrupt (fault/debug/guest-exit) > static final int TRAP = 35; static final int OPCODE_COUNT = 36; int defined; void configure() { defined = OPCODE_COUNT; } boolean valid(int opcode) { return opcode >= 0 && opcode < OPCODE_COUNT; } boolean isBranch(int opcode) { return opcode == JMP || opcode == JZ || opcode == JNZ || opcode == JLT || opcode == JGE || opcode == CALL || opcode == RET; } boolean isMemory(int opcode) { return opcode >= LOAD && opcode <= STOREX; } boolean isArithmetic(int opcode) { return opcode >= ADD && opcode <= SHR; } boolean isStack(int opcode) { return opcode == CALL || opcode == RET || opcode == PUSH || opcode == POP; } boolean isIO(int opcode) { return opcode == IN || opcode == OUT; } boolean isSystem(int opcode) { return opcode == SYSCALL || opcode == TRAP; } String mnemonic(int opcode) { if (opcode == NOP) { return "NOP"; } if (opcode == HALT) { return "HALT"; } if (opcode == MOV) { return "MOV"; } if (opcode == MOVR) { return "MOVR"; } if (opcode == LOAD) { return "LOAD"; } if (opcode == LOADR) { return "LOADR"; } if (opcode == LOADX) { return "LOADX"; } if (opcode == STORE) { return "STORE"; } if (opcode == STORER) { return "STORER"; } if (opcode == STOREX) { return "STOREX"; } if (opcode == ADD) { return "ADD"; } if (opcode == SUB) { return "SUB"; } if (opcode == MUL) { return "MUL"; } if (opcode == DIV) { return "DIV"; } if (opcode == MOD) { return "MOD"; } if (opcode == NEG) { return "NEG"; } if (opcode == AND) { return "AND"; } if (opcode == OR) { return "OR"; } if (opcode == XOR) { return "XOR"; } if (opcode == NOT) { return "NOT"; } if (opcode == SHL) { return "SHL"; } if (opcode == SHR) { return "SHR"; } if (opcode == CMP) { return "CMP"; } if (opcode == JMP) { return "JMP"; } if (opcode == JZ) { return "JZ"; } if (opcode == JNZ) { return "JNZ"; } if (opcode == JLT) { return "JLT"; } if (opcode == JGE) { return "JGE"; } if (opcode == CALL) { return "CALL"; } if (opcode == RET) { return "RET"; } if (opcode == PUSH) { return "PUSH"; } if (opcode == POP) { return "POP"; } if (opcode == IN) { return "IN"; } if (opcode == OUT) { return "OUT"; } if (opcode == SYSCALL) { return "SYSCALL"; } if (opcode == TRAP) { return "TRAP"; } return "???"; } int opcodeCount() { return OPCODE_COUNT; } }