Figured out termios

This commit is contained in:
Luxferre
2022-08-16 11:51:49 +03:00
parent f5fe3b6a15
commit 859e4b3108
2 changed files with 38 additions and 23 deletions
+7 -5
View File
@@ -4,6 +4,8 @@ Equi is a general-purpose 16-bit stack-based platform (and a programming languag
The name Equi comes from the fact each source code instruction is **equi**valent to a machine instruction. No, it isn't mapped to one machine instruction. It **is the** machine instruction. All the instructions and data in Equi are represented with printable ASCII characters only. This allows to bootstrap Equi code directly from the keyboard (any standard keyboard/keypad that allows serial input) using a tiny interpreter stored, for instance, in the hardware ROM.
This document describes a more-or-less formal specification. For a tutorial on how to use it, please read the [Programming in Equi](programming-in-equi.md) book.
## Specification
Main features of an Equi machine:
@@ -84,16 +86,16 @@ Op |Stack state |Meaning
`:`|`( -- )` |Compilation mode start: set CM flag and set CBP to PC+1 value
`;`|`( -- )` |Compilation mode end: replace this instruction in-memory with `R` instruction, pop all characters from the literal stack, append the lookup table with their CRC16 hash and CBP value, unset the CM flag and increment CLTP value
`'`|`( -- )` |Call the compiled word: pop all characters from the literal stack, compute their CRC16 hash, look it up in CLT for a CBP value, set PC to CBP if found, error out if not, then push PC to return stack and set PC to the CBP value
`R`|`( -- )` |**R**eturn: pop and assign the PC value from the return stack
`]`|`( a -- )` |Pop the value from main stack and push onto return stack
`[`|`( -- a )` |Pop the value from return stack and push onto main stack
`R`|R: `( a -- )` |**R**eturn: pop and assign the PC value from the return stack
`]`|M: `( a -- )` R: `( -- a )` |Pop the value from main stack and push onto return stack
`[`|M: `( -- a )` R: `( a -- )` |Pop the value from return stack and push onto main stack
`L`|`( addr -- a` ) |**L**oad a 16-bit value from `addr`
`S`|`( a addr -- )` |**S**tore a 16-bit value into `addr`
`W`|`( a addr -- )` |**W**rite a 8-bit value into `addr` (note that both value and address still must be 16-bit, the higher byte of the value is discarded)
`!`|`( a -- )` |Drop the top value from the stack
`$`|`( a -- a a )` |Duplicate the top value on the stack
`%`|`( a b -- b a )` |Swap two top values on the stack
`@`|`( a b c -- b c a )` |Rotate three top values on the stack
`%`|`( a b -- b a )` |Swap top two values on the stack
`@`|`( a b c -- b c a )` |Rotate top three values on the stack
`\`|`( a b -- a b a )` |Copy over the second value on the stack
`J`|`( rel -- )` |**J**ump: increase or decrease PC according to the relative value (treated as signed, from -32768 to 32767)
`I`|`( cond rel -- ) ` |Pop relative value and condition. **I**f the condition value is not zero, `J` to the relative value