esop

Essential Stack-Operated Phone (concept)
git clone git://git.luxferre.top/esop.git
Log | Files | Refs | README | LICENSE

commit 8f6db1975bdc37d888a0bc4d1608c04be73f31fc
parent 446d99ea6fcedd11feb5bf150f59e72a220d4898
Author: Luxferre <lux@ferre>
Date:   Thu, 28 Jul 2022 18:23:04 +0300

Fixed ID table to match srht

Diffstat:
MREADME.md | 70+++++++++++++++++++++++++++++++++++-----------------------------------
1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/README.md b/README.md @@ -18,13 +18,13 @@ ESOP's hardware was largely inspired by Nokia 5110 family and some other ideas c The 64K of memory are arranged as follows (size is specified in bytes in decimal): -Addresses |Size |Purpose ----------------|-----|------------------- -`0x0000-0xfbff`|64512|Uxn application RAM -`0xfc00-0xfcff`|256 |Uxn work stack -`0xfd00-0xfdff`|256 |Uxn return stack -`0xfe00-0xfff7`|504 |Video memory -`0xfff8-0xffff`|8 |Control block +Addresses |Size |Purpose +-----------|-----|------------------- +`0000-fbff`|64512|Uxn application RAM +`fc00-fcff`|256 |Uxn work stack +`fd00-fdff`|256 |Uxn return stack +`fe00-fff7`|504 |Video memory +`fff8-ffff`|8 |Control block Every ESOP implementation must emulate the exact same memory layout as per this table. @@ -40,20 +40,20 @@ In Uxntal, the ESOP's control block would be described as follows: The fields of the control block are: -- Frame vector (`0x00-0x01`) - the port to set the vector to be run on each frame (60 frames per second); -- Input (`0x02-0x03`) - the port to read input status bits of every key on the keypad; -- Random/debug port (`0x04`) - the port to trace debug information on output and retrieve a random byte value on input; -- Status port (`0x05`) - the port to get the information on battery and get/set screen brightness level; -- Sound port (`0x06`) - the port to perform mono audio beeper operations; -- Syscall port (`0x07`) - the port to run system calls to the phone's underlying operating system. +- Frame vector (`00-01`) - the port to set the vector to be run on each frame (60 frames per second); +- Input (`02-03`) - the port to read input status bits of every key on the keypad; +- Random/debug port (`04`) - the port to trace debug information on output and retrieve a random byte value on input; +- Status port (`05`) - the port to get the information on battery and get/set screen brightness level; +- Sound port (`06`) - the port to perform mono audio beeper operations; +- Syscall port (`07`) - the port to run system calls to the phone's underlying operating system. -Implementation note: direct writing to or reading from the control block memory area must have the same effect as calling the corresponding `DEO`/`DEI` instructions. E.g. if the application directly stores a byte into `0xffff`, the runtime must consider it writing to the `0x07` control port and process it as a system call. +Implementation note: direct writing to or reading from the control block memory area must have the same effect as calling the corresponding `DEO`/`DEI` instructions. E.g. if the application directly stores a byte into `#ffff`, the runtime must consider it writing to the `07` control port and process it as a system call. ## Screen output -All the 4032 pixels of 84x48 screen are allocated in the 504-byte video memory of ESOP (`0xfe00-0xfff7`) in the left-to-right, top-to-bottom, high-to-low order. To output a pixel at the given coordinates, the app must calculate the appropriate byte position itself. +All the 4032 pixels of 84x48 screen are allocated in the 504-byte video memory of ESOP (`#fe00-#fff7`) in the left-to-right, top-to-bottom, high-to-low order. To output a pixel at the given coordinates, the app must calculate the appropriate byte position itself. -The actual screen contents get updated 60 times per second according to the video memory. Before this process, the frame vector is run, if set in the corresponding control port (`0x00-0x01`). +The actual screen contents get updated 60 times per second according to the video memory. Before this process, the frame vector is run, if set in the corresponding control port (`00-01`). Standard input/output ports are not supported. @@ -69,13 +69,13 @@ The `A` (Advance), `B` (Back), `C` (Cancel) and `D` (Do) keys should be implemen ## Random/debug port -The `0x04` port must return a random byte from 0 to 255 when read from, and initiate the stack trace print to the runtime when written to. Since standard output is not supported by ESOP, it is up to the runtime to decide where to output the debug information. +The `04` port must return a random byte from 0 to 255 when read from, and initiate the stack trace print to the runtime when written to. Since standard output is not supported by ESOP, it is up to the runtime to decide where to output the debug information. -Just like with SPARTA, it's entirely up to the implementation to choose the randomness source, to implement a truly random or a secure enough pseudorandom generator. From the Uxn/ESOP application standpoint, the byte value obtained from the `0x04` port (or `0xfffc` memory address) must be considered truly random and not derived from anything else. +Just like with SPARTA, it's entirely up to the implementation to choose the randomness source, to implement a truly random or a secure enough pseudorandom generator. From the Uxn/ESOP application standpoint, the byte value obtained from the `04` port (or `#fffc` memory address) must be considered truly random and not derived from anything else. ## Status port -The `0x05` port is divided as follows: +The `05` port is divided as follows: Bits |7 |6-4 |3-0 -------|---------------|-------------|--------------------------- @@ -87,23 +87,23 @@ The lower nibble (bits 0 to 3) of the status can be modified from the applicatio ## Sound output -ESOP supports monophonic sound output with a beeper controllable via `0x06` port. As long as the port value is non-zero, the beeper must emit a sound wave of the specified frequency. The frequency is specified in semitones relative to A4 (440 Hz), with A4 itself being located at `0x30` value. +ESOP supports monophonic sound output with a beeper controllable via `06` port. As long as the port value is non-zero, the beeper must emit a sound wave of the specified frequency. The frequency is specified in semitones relative to A4 (440 Hz), with A4 itself being located at `30` value. ## System calls -ESOP supports up to 32 different system calls (syscalls), with up to 7 byte parameters each. The command byte passed to the `0x07` port is arranged as follows: +ESOP supports up to 32 different system calls (syscalls), with up to 7 byte parameters each. The command byte passed to the `07` port is arranged as follows: Bits |7-5 |4-0 -------|--------------------|---------- Meaning|number of parameters|syscall ID -Number of parameters determines how many subsequent writes to the syscall port the runtime must process as parameter pass as opposed to the syscall invokation. For instance, if we run `#8a #07 DEO`, it means we're starting the syscall `0x0a` with four byte (or two short) parameters expected to pass afterwards using the same `0x07` port. +Number of parameters determines how many subsequent writes to the syscall port the runtime must process as parameter pass as opposed to the syscall invokation. For instance, if we run `#8a #07 DEO`, it means we're starting the syscall `0a` with four byte (or two short) parameters expected to pass afterwards using the same `07` port. To distinguish between command byte and parameter byte, command byte must never be equal to zero. I.e. a hypothetical syscall with ID 0 and no parameters would be invalid by definition. The syscall port cannot be read from, but runtime has the full access to application's memory during the syscall, and can write some information into it as the result. -The only system call required to be implemented in any ESOP-compatible runtime is `0x1f`, the halting call. In addition to that, system calls can extend the basic ESOP functionality with: +The only system call required to be implemented in any ESOP-compatible runtime is `1f`, the halting call. In addition to that, system calls can extend the basic ESOP functionality with: - serial/debug port I/O; - persistent/flash memory I/O (up to 16 MB), operating with 256-byte pages or individual bytes; @@ -119,23 +119,23 @@ The only system call required to be implemented in any ESOP-compatible runtime i - STK calls; - loading and invoking other Uxn/ESOP programs from the persistent memory. -On call completion, the `0x07` port value must be set to zero by the ESOP runtime. +On call completion, the `07` port value must be set to zero by the ESOP runtime. ### Recommended syscall table -hex ID|Params |Command|Meaning +ID |Params |Command|Meaning ------|-----------------|-------|---------------------------------- -`00` |1b [data] |`0x20` |Write a byte to serial/debug port -`01` |1s [addr] |`0x41` |Read a byte from serial/debug port -`02` |1b 3b [data addr]|`0x82` |Write a byte under the 3-byte flash address -`03` |1s 3b [addr addr]|`0xa3` |Read a byte under the 3-byte flash address -`04` |1b 3b [page addr]|`0x84` |Write a page under the 3-byte flash address -`05` |1b 3b [page addr]|`0x85` |Read a page under the 3-byte flash address -`06` |1s [addr] |`0x46` |Read the current system time/date information (5 bytes/40 bits, Unix time) into the address -`07` |1s [addr] |`0x47` |Set the current system time/date information (5 bytes/40 bits, Unix time) from the address +`00` |1b [data] |`20` |Write a byte to serial/debug port +`01` |1s [addr] |`41` |Read a byte from serial/debug port +`02` |1b 3b [data addr]|`82` |Write a byte under the 3-byte flash address +`03` |1s 3b [addr addr]|`a3` |Read a byte under the 3-byte flash address +`04` |1b 3b [page addr]|`84` |Write a page under the 3-byte flash address +`05` |1b 3b [page addr]|`85` |Read a page under the 3-byte flash address +`06` |1s [addr] |`46` |Read the current system time/date information (5 bytes/40 bits, Unix time) into the address +`07` |1s [addr] |`47` |Set the current system time/date information (5 bytes/40 bits, Unix time) from the address `08-1d`|||(reserved) -`1e` |1b 3b [flag addr]|`0x8e`|Load and run another Uxn/ESOP application from flash address according to the flags -`1f` |None |`0x1f`|Halt (required) +`1e` |1b 3b [flag addr]|`8e` |Load and run another Uxn/ESOP application from flash address according to the flags +`1f` |None |`1f` |Halt (required) ## Credits