HZCode
A Befunge of Chinese characters, run by a queue of instruction pointers.
None1, 2023 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 6 known programs · Test method
Run it
The idea
None1 made HZCode from Chinese characters, taking the idea from Aheui and most commands from Befunge. The name comes from 汉字, hanzi. Each command is a word that says what it does: 加 is add, 说 is say, 停 is stop, 上 下 左 右 are up, down, left and right. Numbers are written with the Chinese numerals. Instead of one instruction pointer there is a queue of them. The one at the front runs one character and goes to the back, so several pointers take turns.
The machine
Each pointer has two stacks of unsigned integers; popping an empty one gives 0.
| Characters | Do |
|---|---|
| 上 下 左 右 | Face up, down, left, right |
| 分 反 | Turn right or left by the top; turn round if it is not 0 |
| 跳 移 | Jump to a row and column; skip to the next 移 |
| 双 停 | Start a new pointer; stop this one |
| 出 入 换 去 复 | Move between the stacks, swap them, pop, duplicate |
| 听 说 读 写 | Read or print a number, read or print a character |
| 升 降 加 减 乘 除 余 | One up, one down, +, −, ×, ÷, mod |
| 随 | Push 0 or 1 at random |
| 零 to 九, 十 百 千 万 亿 兆 | Push 0 to 9, 10, 100, 1000, 10^4, 10^8, 10^12 |
Subtraction stops at 0, and dividing by 0 gives 0. The program ends when the last pointer stops. This implementation draws 随 from a fixed sequence so that a run repeats.
Example
In the second program the first pointer starts a second one on the row below and prints d.
In the second program the first pointer starts a second one on the row below and prints d. The new pointer then takes its turn and prints o. The pi program holds 1,960 升 and multiplies them by 16, so it prints 31360, not the 3136 the specification gives.
Further
Ideas it shows
See also
Concurrent programming
CJK
Write your own in Run Convert a program from HZCode
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: hzcode.
Command line
shib run hzcode -e '四说停'shib manual hzcodeSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/hzcode.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org