Mirror of CollapseOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

shell.md 2.7KB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # shell
  2. The shell is a text interface giving you access to commands to control your
  3. machine. It is not built to be user friendly, but to minimize binary space and
  4. maximize code simplicity.
  5. We expect the user of this shell to work with a copy of the user guide within
  6. reach.
  7. It is its design goal, however, to give you the levers you need to control your
  8. machine fully.
  9. ## Commands and arguments
  10. You invoke a command by typing its name, followed by a list of arguments. All
  11. numerical arguments have to be typed in hexadecimal form, without prefix or
  12. suffix. Lowercase is fine. Single digit is fine for byte (not word) arguments
  13. smaller than `0x10`. Example calls:
  14. mptr 01ff
  15. peek 4
  16. poke 1f
  17. call 00 0123
  18. All numbers printed by the shell are in hexadecimals form.
  19. Whenever a command is malformed, the shell will print `ERR` with a code. This
  20. table describes those codes:
  21. | Code | Description |
  22. |------|---------------------------|
  23. | `01` | Unknown command |
  24. | `02` | Badly formatted arguments |
  25. | `03` | Out of bounds |
  26. | `04` | Unsupported command |
  27. | `05` | I/O error |
  28. Applications have their own error codes as well. If you see an error code that
  29. isn't in this list, it's an application-specific error code.
  30. ## mptr
  31. The shell has a global memory pointer (let's call it `memptr`) that is used by
  32. other commands. This pointer is 2 bytes long and starts at `0x0000`. To move
  33. it, you use the mptr command with the new pointer position. The command
  34. prints out the new `memptr` (just to confirm that it has run). Example:
  35. > mptr 42ff
  36. 42FF
  37. ## peek
  38. Read memory targeted by `memptr` and prints its contents in hexadecimal form.
  39. This command takes one byte argument (optional, default to 1), the number of
  40. bytes we want to read. Example:
  41. > mptr 0040
  42. 0040
  43. > peek 2
  44. ED56
  45. ## poke
  46. Puts the serial console in input mode and waits for a specific number of
  47. characters to be typed (that number being specified by a byte argument). These
  48. characters will be literally placed in memory, one after the other, starting at
  49. `memptr`.
  50. Example:
  51. > poke 5
  52. Hello
  53. > peek 5
  54. 48656C6C6F
  55. ## call
  56. Calls the routine at `memptr`, setting the `A` and `HL` registers to the value
  57. specified by its optional arguments (default to 0).
  58. Be aware that this results in a call, not a jump, so your routine needs to
  59. return if you don't want to break your system.
  60. The following example works in the case where you've made yourself a jump table
  61. in your glue code a `jp printstr` at `0x0004`:
  62. > mptr a000
  63. A000
  64. > poke 6
  65. Hello\0 (you can send a null char through a terminal with CTRL+@)
  66. > mptr 0004
  67. 0004
  68. > call 00 a000
  69. Hello>