SLInstruction.sleela
lib/cpu/SLInstruction.sleela · 77 line(s) · sleela
<< lib/cpu/SLInstruction.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLInstruction — one decoded machine instruction: an
opcode plus up to two register operands and an immediate/address field.
This is the unit the fetch stage produces and the execute stage consumes.
Encoding (modeled): [opcode][rd][rs][imm]. A real ISA packs these into fixed-
or variable-width words; here they are fields for clarity.
Family: cpu. Pure Sleela data. >>
#sleela 2.5
material;
class SLInstruction {
< ---- 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 = 10252;
String metaAuthor = "Kiro Agent";
String metaDate = "2026-10-16";
String metaCopyright = "SLeeLa project";
String metaTrademark = "none";
String metaCorporation = "none";
< metaOrigin: National | <nation> | 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; }
int opcode;
< destination register index >
int rd;
< source register index >
int rs;
< immediate value or memory/branch address >
int imm;
void configure(int op, int dest, int src, int immediate) {
opcode = op; rd = dest; rs = src; imm = immediate;
}
int op() { return opcode; }
int dest() { return rd; }
int src() { return rs; }
int immediate() { return imm; }
< Pack into a single word for storage in RAM (modeled fixed layout). >
int encode() {
return ((opcode % 256) * 16777216) + ((rd % 256) * 65536) + ((rs % 256) * 256) + (imm % 256);
}
}