Exemoji

From Esolang
Jump to navigation Jump to search
Exemoji
Paradigm(s) imperative
Designed by User:Glax
Appeared in 2024
Memory system Cell-based
Dimensions one-dimensional
Computational class Turing complete
Reference implementation exemoji.py
Influenced by x86
File extension(s) .yip, .yap

Exemoji is an 8bit computer architecture based on emoji.

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

Playground

There is a web-based virtual machine that can execute and debug exemoji bytecode.

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 value by that many bytes, otherwise after the next occurrence of that emoji
πŸ‘ˆ Jump back emo₁ Jumps backwards, if emo₁ is an immediate value 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 value 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

Interrupts allow you to perform output operations

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 🐱

Examples

Hello World

This prints "Hello World" from a string stored explicitly in memory:

πŸ‘πŸžπŸ½πŸ‰πŸπŸ‘πŸ±πŸŒπŸ˜πŸ¦–πŸ§ πŸ²πŸ―πŸžπŸ€ŒπŸ‰πŸ€–πŸŽπŸ˜’πŸŽπŸžπŸ²πŸ‘ˆπŸ¦–πŸ‰πŸ« Hello World\n\0

The following code also prints "Hello World" but the characters are evaulated with code instead of being stored in memory:

πŸ«ΈπŸ¦πŸ‘πŸžπŸ½πŸ‰πŸŠπŸ«ΈπŸžπŸ‘πŸ±πŸπŸ˜’πŸ«ΈπŸ²πŸ‘πŸ±πŸ₯­πŸ˜’πŸ«ΈπŸ²πŸ‘πŸ±πŸ‹πŸ˜’πŸ«ΈπŸ²πŸ‘πŸ±πŸ₯₯πŸ¦ŠπŸ«ΈπŸ²πŸ‘πŸ±πŸ½πŸŠπŸŠπŸ¦ŠπŸ«ΈπŸ²πŸ‘πŸ±πŸ‹πŸ˜’πŸ«ΈπŸ²πŸ‘πŸ±πŸπŸ˜’πŸ«ΈπŸ²πŸ«ΈπŸ²πŸ‘πŸ±πŸŒπŸ˜’πŸ«ΈπŸ²πŸ‘πŸ±πŸ½πŸŒπŸˆπŸ¦ŠπŸ«ΈπŸ²πŸ˜πŸ¦–πŸ’₯πŸ²πŸ€ŒπŸ‰πŸ€–πŸŽπŸ‘ˆπŸ¦–πŸ‰πŸ« 

FizzBuzz

The classic FizzBuzz:

πŸ‘πŸžπŸŽπŸ‘‰πŸ½πŸŠπŸπŸ‘πŸ²πŸ’πŸ€–πŸŽπŸ‘πŸ±πŸ½πŸ‰πŸŠπŸ§πŸ€ŒπŸ½πŸŽπŸπŸ‘‰πŸŠπŸ« πŸ‘πŸ±πŸŒπŸ˜’πŸŽπŸžπŸ²πŸ‘πŸ±πŸ†πŸ–•πŸŽπŸ²πŸ¦πŸ€ŒπŸ½πŸπŸŽπŸ‘πŸ±πŸ«πŸ–•πŸŽπŸ²πŸ¦πŸ€ŒπŸ½πŸ“πŸŽπŸ‘πŸ±πŸ‡πŸ–•πŸŽπŸ²πŸ¦πŸ€ŒπŸ½πŸπŸˆπŸ›«πŸπŸ½πŸ‰πŸŽπŸ¦ΈπŸŽπŸ½πŸŒπŸˆπŸ›«πŸŒπŸ½πŸ‹πŸπŸ›«πŸπŸ½πŸŒπŸπŸ¦ΈπŸŽπŸ½πŸŒπŸˆπŸ›«πŸŒπŸ½πŸ‹πŸπŸ¦ΈπŸŽπŸ½πŸŒπŸˆπŸ›«πŸπŸ½πŸŒπŸπŸ¦ΈπŸŽπŸ½πŸŒπŸˆπŸ‘πŸ²πŸ½πŸŠπŸ‰πŸ€–πŸŽπŸ‘πŸ²πŸ½πŸ‰πŸ“πŸ€–πŸŽπŸ‘πŸ²πŸ½πŸ₯πŸ’πŸ€–πŸŽπŸ€–πŸŽπŸ›¬πŸ‘πŸ²πŸ½πŸŠπŸπŸ€–πŸŽπŸ‘πŸ²πŸ½πŸ₯πŸ‡πŸ€–πŸŽπŸ‘ˆπŸ½πŸ₯πŸŽπŸ«ΈπŸžπŸ‘πŸ¦„πŸŽπŸ‘πŸ¦œπŸŽπŸ‘πŸ±πŸ’πŸ–•πŸŽπŸžπŸ²πŸŽπŸ¦œπŸ¦πŸ–•πŸŽπŸžπŸ²πŸŽπŸ¦„πŸ¦πŸ–•πŸŽπŸžπŸ¦πŸ‘πŸ±πŸ½πŸ«πŸŽπŸŽπŸ²πŸ¦πŸ€ŒπŸˆπŸ˜’πŸ€–πŸŽπŸŽπŸžπŸ¦„πŸŽπŸ²πŸ¦„πŸ€ŒπŸˆπŸ˜’πŸ€–πŸŽπŸŽπŸžπŸ¦œπŸ˜’πŸ€–πŸŽπŸ’₯πŸžπŸ›¬

Graphics

This example uses the graphics interrupts to draw a house:

πŸ€–πŸ½πŸŒπŸŽπŸ‘πŸžπŸ½πŸ†πŸ†πŸ€–πŸ½πŸŒπŸŠπŸ‘πŸ―πŸ½πŸ«πŸŠπŸ‘πŸ¦„πŸ½πŸŒπŸ‰πŸ›«πŸ«πŸ½πŸ«πŸπŸ€–πŸ½πŸπŸŽπŸ‘πŸžπŸ½πŸ₯πŸ†πŸ‘πŸ±πŸ½πŸŒπŸŽπŸ€–πŸ½πŸπŸπŸ‘πŸžπŸ½πŸ‡πŸŽπŸΈπŸžπŸ±πŸ€–πŸ½πŸπŸ«πŸ‘πŸžπŸ½πŸ₯­πŸ†πŸ€–πŸ½πŸπŸ«πŸ€–πŸ½πŸŒπŸ‡πŸ€–πŸ½πŸπŸŽπŸ‘πŸžπŸ½πŸπŸŽπŸ«ΈπŸžπŸ€–πŸ½πŸπŸπŸ‘πŸžπŸ½πŸ₯₯πŸ†πŸ€–πŸ½πŸπŸ«πŸ‘πŸ±πŸ½πŸ†πŸ†πŸ€–πŸ½πŸπŸ«πŸ‘πŸžπŸŽπŸ˜’πŸ‘πŸ±πŸ½πŸ†πŸ†πŸ€–πŸ½πŸŒπŸŠπŸ’₯πŸžπŸ€–πŸ½πŸπŸ«πŸ€–πŸ½πŸŒπŸ‡πŸŽπŸžπŸ±πŸŽπŸ²πŸ±πŸ€–πŸ½πŸŒπŸŠπŸ‘πŸ―πŸ½πŸ«πŸŽπŸ‘πŸ¦„πŸ½πŸ‰πŸŽπŸ›«πŸ«πŸ½πŸ«πŸπŸ‘πŸ―πŸ½πŸ₯πŸŽπŸ›«πŸ«πŸ½πŸ«πŸπŸ‘πŸ―πŸ½πŸ’πŸ†πŸ›«πŸ«πŸ½πŸ«πŸπŸŽπŸ¦„πŸ―πŸ›«πŸ«πŸ½πŸ«πŸπŸ‘πŸ―πŸ½πŸ«πŸŽπŸ›«πŸ«πŸ½πŸ«πŸπŸ‘πŸ―πŸ½πŸ₯πŸŽπŸ‘πŸ¦„πŸ½πŸˆπŸŽπŸ›«πŸ«πŸ½πŸ«πŸπŸ« πŸ€–πŸ½πŸπŸŽπŸŽπŸžπŸ―πŸŽπŸ±πŸ¦„πŸ€–πŸ½πŸπŸπŸ‘πŸ±πŸ½πŸπŸŽπŸ˜’πŸ«ΈπŸ²πŸŽπŸ±πŸ¦„πŸΈπŸ²πŸžπŸ€–πŸ½πŸπŸ«πŸŽπŸžπŸ¦„πŸ‘πŸ±πŸ½πŸ«πŸŽπŸ˜’πŸΈπŸ±πŸ²πŸ’₯πŸžπŸ€–πŸ½πŸπŸ«πŸŽπŸžπŸ―πŸ€–πŸ½πŸπŸ«πŸ€–πŸ½πŸŒπŸ‡πŸ›¬

Output:

External Links

  • Glax's site contains a description of the and a web-based interpreter and debugger.
  • exemoji.py Python-based interpreter of the language