Updated specifications with debug instruction

This commit is contained in:
jan 2025-01-06 14:39:38 +01:00
parent af51204ed5
commit c846b26da9

View File

@ -167,7 +167,11 @@ All instructions are listed in @instructions.
table.header(
[*Opcode*], [*Name*],[*Effect*],
),
[0],[*Set*],[`@arg1=arg2`],
[0],[*Set*],[`if arg3{
@arg1=inst_ptr
}else{
@arg1=arg2
}`],
[1],[*GoTo*],[`if(not @arg3){inst_ptr=@arg1+arg2}`],
[2],[*Skip*],[
```
@ -183,7 +187,7 @@ All instructions are listed in @instructions.
[7],[*Cmp*],[`@arg3=(@arg1<@arg2)` (as unsigned)],
[8],[*Deref*],[`@arg2=@(@arg1+arg3)`],
[9],[*Ref*],[`@(@arg1+arg3)=@arg2`],
[10],[*Inst*],[`@arg1=inst_ptr`],
[10],[*Debug*],[Provides `arg1,@arg2,@arg3` as debug information],
[11],[*Print*],[Writes `value=@arg1` to `index=@arg2` of buffer `arg3`],
[12],[*Read*],[Copies `index=@arg1` of buffer `arg3` to `@arg2`.],
[13],[*Band*],[`@arg3=@arg1&@arg2` (binary and)],
@ -200,6 +204,20 @@ Every instruction shown in @instructions advances the instruction pointer by fou
When an argument refers to the name of a buffer, it means the screen buffer if it is 0 and the utility buffer otherwise.
== The Debug Instruction
The *Debug* instruction is special, as it does not change anything about the state of the system.
It still counts as an instruction for the maximum instruction count.
It is up to the implementation if, when and in what way the information is provided to the user.
This means that it is valid to not do anything when the instruction is triggered.
In fact, this might be necessary to run the emulator at the intended speed.
The way to think about the signature of the instruction is that the first argument is a label and the other arguments are the values of variables/addresses.
The instruction is meant only for debugging.
For the programmer that means that the output should not be needed for the use of the program or game as it might be shown in different ways or not at all.
For the emulator that means that there should be no functionality that depends on the *Debug* instruction.
= Constructing the Program
A program is really just the initial state of the main memory.