Rules
Specifications
All SAP programs fit in 16 addresses (0 to 15) because the program counter (
PC) is 4-bit. [1]The initial state of a SAP program is
{PC: 0, Register A: 0, Register B: 0, FlagC: 0, FlagZ: 0, Executing: 1}. [2]AandBregisters are 8-bit by default. [3] The bit patterns are always interpreted as unsigned integers by SAPsim.If the registers are interpreted as unsigned ints, what would 0-1 be? What about 255+1? See this footnote for the answer. [4]
General
Everything in RAM is a byte. [5] Therefore, instructions and data are both represented as a First Hexit and Second Hexit.
An instruction’s First Hexit is its 2 or 3 letter Mnemonic. An instruction’s Second Hexit is its Arg.
An instruction’s Arg can be represented in base-10 or base-16.
For example,
JC 15could also be written asJC F.
All data must fit in a byte.
For example, 254 =
0xFEis First HexitF, Second HexitE.10 =
0x0Ais First Hexit0, Second HexitA. You may not omit the leading 0.
Programs run until they
HLTor until an Exception is raised. Infinite loops are possible, of course.
Note
These are the same rules a SAP computer implemented by hardware has to follow.
“This is a feature, not a bug”
Allowed syntax
In the First Hexit column, these are allowed
Two or three letter Mnemonic [6]
Hexit
0toFDouble digit base-10 integer
10to15representing a hexit
In the Second Hexit column, these are allowed
Hexit
0toFDouble-digit base-10 integer
10to15representing a hexite.g.
JC 15andJC Fare both legal and represent the same instruction