Exemoji

Specs

Exemoji is an 8bit computer architecture based on emoji.

Instructions are sequences of utf8-encoded emoji, making executables valid text files.

Registers

Exemoji supports 8 general-purpose 8bit registers:

Register Index Special Use
🐞 0 Left handside operand for mathematical operations
🐱 1 Right handside operand for mathematical operations
🐲 2 Main result for mathematical operations
🐦 3 Secondary result for mathematical operations
🐯 4
πŸ¦„ 5
🦜 6
🐻 7

In addition to these, there are two 16 bit registers, the program counter (PC) and stack pointer (SP), which are affected by specific instructions.

Immediates

Immediate values can be directly encoded by bytes but this will sometimes result in invalid utf-8 sequences, as such there is an emoji alternative to encode immediate values

A nibble can be represented by one of the following emoji:

Code Hex Dec
🍎 0 0
🍌 1 1
🍐 2 2
🫐 3 3
🍊 4 4
πŸ‡ 5 5
πŸ‰ 6 6
πŸ₯ 7 7
🍍 8 8
πŸ“ 9 9
πŸ’ a 10
πŸ‹ b 11
🍈 c 12
πŸ₯₯ d 13
πŸ₯­ e 14
πŸ† f 15

To represent a full byte (octet), you need to prefix the immediate with 🍽 followed by two nibble emoji.

Instructions

Opcode Name Operands Description
🐸 Swap reg₁ regβ‚‚ Swaps the value of reg₁ and regβ‚‚
πŸ‘ Assign reg₁ immβ‚‚ Assigns immβ‚‚ to reg₁
🎁 Move reg₁ regβ‚‚ Assigns the value of regβ‚‚ to reg₁
🫸 Push reg₁ Pushes reg₁ into the stack, incrementing the stack pointer
πŸ’₯ Pop reg₁ Pops reg₁ from the stack, decrementing the stack pointer
πŸ’Ύ Load from SP reg₁ regβ‚‚ Loads into reg₁ the memory location regβ‚‚ bytes before the stack pointer
🧠 Load Long reg₁ regβ‚‚ reg₃ Loads in reg₁ the absolute memory address obtained by combining regβ‚‚ and reg₃
πŸ–Š Store Long reg₁ regβ‚‚ reg₃ Stores reg₁ at the absolute memory address obtained by combining regβ‚‚ and reg₃
🍦 Trigonometry Polar coordinates of 🐞 as an angle (2pi = 256) and 🐱 as length, offset by 127. 🐲 will be x and 🐦 will be y
😒 Add Adds 🐞 to 🐱, storing the result in 🐲 and overflow in 🐦
🦊 Subtract Subtracts 🐱 from 🐞, storing the result in 🐲, if the result is negative, 🐦 will hold the absolute value of the negative result
🐰 Multiply Multiplies 🐞 to 🐱, storing the result in 🐲 and overflow in 🐦
πŸ–• Divide Divides 🐞 by 🐱, storing the result in 🐲 and remainder in 🐦
🦁 Or Bitwise OR between 🐞 and 🐱, storing the result in 🐲
πŸͺ’ Not Bitwise NOT of 🐞, storing the result in 🐲
🦝 And Bitwise AND between 🐞 and 🐱, storing the result in 🐲
πŸ• Xor Bitwise XOR between 🐞 and 🐱, storing the result in 🐲
🧐 Compare Compares 🐞 and 🐱, storing the result in 🐲: 0 if equal, 1 if 🐱 is greater ff if 🐞 is greater
πŸ‘‰ Jump forward emo₁ Jumps forwards, if emo₁ is an immediate vaue by that many bytes, otherwise after the next occurrence of that emoji
πŸ‘ˆ Jump back emo₁ Jumps backwards, if emo₁ is an immediate vaue by that many bytes, otherwise after the previous occurrence of that emoji
🀌 Jump 0 fwd emo₁ Jumps forwards when 🐲 is 0, if emo₁ is an immediate vaue by that many bytes, otherwise after the next occurrence of that emoji
😐 Ignore emo₁ Ignores emo₁
🦸 Long Jump imm₁ immβ‚‚ Jumps to the absolute location obtained by combining imm₁ and immβ‚‚
πŸ›« Call imm₁ immβ‚‚ Pushes the program counter into the stack (most significant byte first) and jumps to the absolute location obtained by combining imm₁ and immβ‚‚
πŸ›¬ Pop PC Pops the program counter from the stack (least significant byte first)
🫠 Halt Stops program execution
πŸ€– Inerrupt imm₁ Generates interrupt imm₁

Some instructions take 16 bit addresses represented as a pair of operands. These are combined by interpreting the first operand as the most significant byte.

Interrupts

Code Effect
Text Output
00 Prints 🐲 as a character to the output
Graphics
10 Enables / clears graphics output
11 Sets graphics stroke color to r 🐞 g 🐱 b 🐲
12 Sets graphics stroke width to 🐞
13 Applies stroke style to the current path
14 Sets graphics fill color to r 🐞 g 🐱 b 🐲
15 Applies fill style to the current path
Graphics Path Commands
20 Begins a new path
21 Closes the current path
22 Moves the path pen to x 🐞 y 🐱
23 Draws a line from pen position to x 🐞 y 🐱

Playground

Here you can execute and debug Exemoji binaries. Note that since this is a debug view loading a program takes some time and execution is rather slow. For running the code faster, you should use the python script.

Initializing virtual machine, please wait...