We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
Comma
comma (always lowercase) is an assembly language for a 4-bit fantasy chip known as the COMM4.
Registers and RAM
comma has access to 256 bytes of RAM, though this does not limit program size as the program is stored in ROM; this means it cannot be changed. Although opcodes are 4 bits wide, the registers A, X, and Y, are 8 bits wide and so are their arguments. When compiling (example: add a, 03), A becomes 0h, X is 1h, and Y is 2h. Hence, the example instruction compiles to 1003h. An address in RAM must be preceded with $, for example, sub x, $2A. All values are in hexadecimal, regardless of if in the form of A8, A8h, 0xA8, or A8_16. Separate from RAM is a 32-byte stack of 8-bit entries. All instructions are encoded into 2 bytes.
Instructions
| Opcode | Mnemonic | Arguments |
|---|---|---|
| 0h | nop | n/a (byte of padding as extra 0h) |
| 1h | add | reg, int |
| 2h | sub | reg, int |
| 3h | cmp | reg, int |
| 4h | jcc | label (compiles to 8-bit label, before label is 4-bit padding) |
| 5h | pus | reg (byte of padding) |
| 6h | pop | reg (byte of padding) |
| 7h | int | int (4-bit) (byte of padding) |
| 8h | xor | reg, int/reg (if reg, when compiled, pad with extra 0) |
| 9h | and | reg, int/reg (if reg, when compiled, pad with extra 0) |
| Ah | nor | reg, int/reg (if reg, when compiled, pad with extra 0) |
| Bh | shl | reg, int |
| Ch | shr | reg, int |
| Dh | mov | reg, int |
| Eh | cll | label (compiles to 8-bit label, before is nibble of 0) |
| Fh | ret | n/a (byte of padding) |
| Opcode | Mnemonic | Form |
|---|---|---|
| 0h | jmp | unconditional |
| 1h | jie | if equal |
| 2h | jne | if not equal |
| 3h | jia | if above |
| 4h | jib | if below |
| 5h | jiz | if zero |
| 6h | jnz | if not zero |
| 7h to Fh | UNDEFINED | program halts |
| Opcode | Type |
|---|---|
| 0h | print (x should hold the value to be printed) |
| 1h | halt |
| 2h | write to disk (x should hold address and y should hold value) |
| 3h | read from disk (x should hold address, value written into y) |
| 4h | input (y holds value) |
| 5h to Fh | UNDEFINED |
Examples
Hello World (minus the world):
mov x, 48h int 0h mov x, 65h int 0h mov x, 6Ch int 0h int 0h mov x, 6Fh int 0h int 1h
which compiles to:
D1 48 70 00 D1 65 70 00 D1 6C 70 00 70 00 D1 6F 70 00 71 00
This can be golfed to:
=x48,0=x65,0=x6C,0,0=x6F,0,1
GolfCOMMA
| Mnemonic | Character |
|---|---|
| nop | . |
| add | + |
| sub | - |
| cmp | ? |
| jcc | see next table |
| pus | : |
| pop | ; |
| int | , |
| xor | X |
| and | A |
| nor | N |
| shl | < |
| shr | > |
| mov | = |
| cll | ( |
| ret | } |
| Mnemonic | Form |
|---|---|
| jmp | # |
| jie | _ |
| jne | ! |
| jia | ^ |
| jib | % |
| jiz | [ |
| jnz | ] |