Halforth
Jump to navigation
Jump to search
Halforth - is an esolang based on Forth by User:ChuckEsoteric08 in which every instruction takes half of a byte (a single hexadecimal digit)
Description
Language works on a stack as well as a tape to store data, which could contain both negative and positive integers
| Command | Opcode | Description |
|---|---|---|
| 0-9 | push x | Push a single digit to the stack |
| A | op | pop operation, a and b and perform b<op>a (see below) |
| B | if | Pop a value, and start if nonzero block |
| C | dup | Duplicates top of the stack |
| D | endif | End if block |
| E | define / ; | Pop a value of and start a procedure definition with that name, which is finished by another E |
| F | exec | Pop a value and execute a procedure with that name |
There is four I/O related procedures which could be executed with and F:
| Procedure name | Opcode | Description |
|---|---|---|
| 0 | out | Pop element from the stack and output it as a number |
| 1 | cout | Pop element from the stack and output it as a character |
| 2 | in | Input a number and push it to the stack |
| 3 | cin | Input a character and push it's value in the stack |
Instructuon A performs operation on the elements using a value of the element above them:
| Value | Opcode | Operation |
|---|---|---|
| 0 | add | Addition |
| 1 | sub | Subtraction |
| 2 | mul | Multiplication |
| 3 | div | Division |
| 4 | less | Less than |
| 5 | eq | Equals |
| 7 | bigger | Bigger than |
| 8 | swap | Swap instruction, pushes b and then a |
| 9 | store | Store value a at index b |
| 10 | load | Push a back, and then load value from index b and push it to the stack |