> I have this implementation of the uxn virtual machine that has 32 instructions, how can we add a few more instrucions do implement memory pagination? (code here)
To implement memory pagination, we can add a few instructions to the existing set of 32 instructions in the uxn virtual machine. These instructions could include:
1. PAGE_IN - This instruction would be used to load a specific page of memory from the underlying storage device into the virtual machine's RAM.
2. PAGE_OUT - This instruction would be used to save a specific page of memory from the virtual machine's RAM to the underlying storage device.
3. SET_PAGE - This instruction would be used to set the current page of memory that is being accessed by the virtual machine.
4. GET_PAGE - This instruction would be used to retrieve the current page of memory that is being accessed by the virtual machine.
These instructions could be implemented as follows:
#define PAGE_IN(x) { u->page = (x); u->dev[0x0f] = 1; }
#define PAGE_OUT(x) { u->dev[0x0f] = 1; }
#define SET_PAGE(x) { u->page = (x); }
#define GET_PAGE(x) { x = u->page; }
int
uxn_eval(Uxn *u, Uint16 pc)
{
...
switch(instr & 0x1f) {
...
case 0x1a: /* PAGE_IN */ PEEK(a, pc) PAGE_IN(a) pc += 1 + bs; break;
case 0x1b: /* PAGE_OUT */ PEEK(a, pc) PAGE_OUT(a) pc += 1 + bs; break;
case 0x1c: /* SET_PAGE */ PEEK(a, pc) SET_PAGE(a) pc += 1 + bs; break;
case 0x1d: /* GET_PAGE */ GET_PAGE(a) PUSH(src, a) break;
...
}
...
Not only these opcodes are already assigned, this would be a very much overkill implementation of this functionality by wasting opcode space, whereas a simple device port would do the trick. It's telling that everyone's first reaction to Uxn is to write a compiler for it, or adding extra memory - it's more about finding fun projects to do that fits within such a restricted space.
> I have this implementation of the uxn virtual machine that has 32 instructions, how can we add a few more instrucions do implement memory pagination? (code here)
To implement memory pagination, we can add a few instructions to the existing set of 32 instructions in the uxn virtual machine. These instructions could include:
1. PAGE_IN - This instruction would be used to load a specific page of memory from the underlying storage device into the virtual machine's RAM. 2. PAGE_OUT - This instruction would be used to save a specific page of memory from the virtual machine's RAM to the underlying storage device. 3. SET_PAGE - This instruction would be used to set the current page of memory that is being accessed by the virtual machine. 4. GET_PAGE - This instruction would be used to retrieve the current page of memory that is being accessed by the virtual machine.
These instructions could be implemented as follows: