Macro esoteric_assembly

Source
macro_rules! esoteric_assembly {
    () => { ... };
    ({} data $data:expr) => { ... };
    ({} DATA $data:expr) => { ... };
    ({} byte $data:expr) => { ... };
    ({} BYTE $data:expr) => { ... };
    ({} nop) => { ... };
    ({} NOP) => { ... };
    ({} ldar $data:expr) => { ... };
    ({} LDAR $data:expr) => { ... };
    ({} ldar) => { ... };
    ({} LDAR) => { ... };
    ({} sba) => { ... };
    ({} SBA) => { ... };
    ({} clř) => { ... };
    ({} CLŘ) => { ... };
    ({} dumpř $data:expr) => { ... };
    ({} DUMPŘ $data:expr) => { ... };
    ({} dumpř) => { ... };
    ({} DUMPŘ) => { ... };
    ({} movař $data:expr) => { ... };
    ({} MOVAŘ $data:expr) => { ... };
    ({} movař) => { ... };
    ({} MOVAŘ) => { ... };
    ({} setř $data0:expr, $data1:expr) => { ... };
    ({} SETŘ $data0:expr, $data1:expr) => { ... };
    ({} setř) => { ... };
    ({} SETŘ) => { ... };
    ({} setř $data:expr) => { ... };
    ({} SETŘ $data:expr) => { ... };
    ({} setiř $data0:expr, $data1:expr) => { ... };
    ({} SETIŘ $data0:expr, $data1:expr) => { ... };
    ({} setiř) => { ... };
    ({} SETIŘ) => { ... };
    ({} setiř $data:expr) => { ... };
    ({} SETIŘ $data:expr) => { ... };
    ({} ldř $data:expr) => { ... };
    ({} LDŘ $data:expr) => { ... };
    ({} ldř) => { ... };
    ({} LDŘ) => { ... };
    ({} ldiř $data:expr) => { ... };
    ({} LDIŘ $data:expr) => { ... };
    ({} ldiř) => { ... };
    ({} LDIŘ) => { ... };
    ({} clß) => { ... };
    ({} CLß) => { ... };
    ({} dumpß $data:expr) => { ... };
    ({} DUMPß $data:expr) => { ... };
    ({} dumpß) => { ... };
    ({} DUMPß) => { ... };
    ({} writeß $data0:expr, $data1:expr) => { ... };
    ({} WRITEß $data0:expr, $data1:expr) => { ... };
    ({} writeß) => { ... };
    ({} WRITEß) => { ... };
    ({} writeß $data:expr) => { ... };
    ({} WRITEß $data:expr) => { ... };
    ({} movaß $data:expr) => { ... };
    ({} MOVAß $data:expr) => { ... };
    ({} movaß) => { ... };
    ({} MOVAß) => { ... };
    ({} setß $data0:expr, $data1:expr) => { ... };
    ({} SETß $data0:expr, $data1:expr) => { ... };
    ({} setß) => { ... };
    ({} SETß) => { ... };
    ({} setß $data:expr) => { ... };
    ({} SETß $data:expr) => { ... };
    ({} setiß $data0:expr, $data1:expr) => { ... };
    ({} SETIß $data0:expr, $data1:expr) => { ... };
    ({} setiß) => { ... };
    ({} SETIß) => { ... };
    ({} setiß $data:expr) => { ... };
    ({} SETIß $data:expr) => { ... };
    ({} ldß $data:expr) => { ... };
    ({} LDß $data:expr) => { ... };
    ({} ldß) => { ... };
    ({} LDß) => { ... };
    ({} pushß) => { ... };
    ({} PUSHß) => { ... };
    ({} popß) => { ... };
    ({} POPß) => { ... };
    ({} lenßa) => { ... };
    ({} LENßA) => { ... };
    ({} ldidp $data:expr) => { ... };
    ({} LDIDP $data:expr) => { ... };
    ({} ldidp) => { ... };
    ({} LDIDP) => { ... };
    ({} Ωchoiceset $data:expr) => { ... };
    ({} ΩCHOICESET $data:expr) => { ... };
    ({} Ωchoiceset) => { ... };
    ({} ΩCHOICESET) => { ... };
    ({} Ωchoicegeta) => { ... };
    ({} ΩCHOICEGETA) => { ... };
    ({} Ωgainapolymorphicdesires) => { ... };
    ({} ΩGAINAPOLYMORPHICDESIRES) => { ... };
    ({} Ωloseapolymorphicdesires) => { ... };
    ({} ΩLOSEAPOLYMORPHICDESIRES) => { ... };
    ({} Ωpushpolymorphicdesires) => { ... };
    ({} ΩPUSHPOLYMORPHICDESIRES) => { ... };
    ({} Ωtheendisnear) => { ... };
    ({} ΩTHEENDISNEAR) => { ... };
    ({} Ωskiptothechase) => { ... };
    ({} ΩSKIPTOTHECHASE) => { ... };
    ({} Ωsetsentience $data:expr) => { ... };
    ({} ΩSETSENTIENCE $data:expr) => { ... };
    ({} Ωsetsentience) => { ... };
    ({} ΩSETSENTIENCE) => { ... };
    ({} Ωsetpaperclipproduction $data:expr) => { ... };
    ({} ΩSETPAPERCLIPPRODUCTION $data:expr) => { ... };
    ({} Ωsetpaperclipproduction) => { ... };
    ({} ΩSETPAPERCLIPPRODUCTION) => { ... };
    ({} addbl) => { ... };
    ({} ADDBL) => { ... };
    ({} subbl) => { ... };
    ({} SUBBL) => { ... };
    ({} mulbl) => { ... };
    ({} MULBL) => { ... };
    ({} divbl) => { ... };
    ({} DIVBL) => { ... };
    ({} modbl) => { ... };
    ({} MODBL) => { ... };
    ({} notl) => { ... };
    ({} NOTL) => { ... };
    ({} andbl) => { ... };
    ({} ANDBL) => { ... };
    ({} orbl) => { ... };
    ({} ORBL) => { ... };
    ({} xorbl) => { ... };
    ({} XORBL) => { ... };
    ({} cmplb) => { ... };
    ({} CMPLB) => { ... };
    ({} tgflag) => { ... };
    ({} TGFLAG) => { ... };
    ({} clflag) => { ... };
    ({} CLFLAG) => { ... };
    ({} addf $data:expr) => { ... };
    ({} ADDF $data:expr) => { ... };
    ({} addf) => { ... };
    ({} ADDF) => { ... };
    ({} subf $data:expr) => { ... };
    ({} SUBF $data:expr) => { ... };
    ({} subf) => { ... };
    ({} SUBF) => { ... };
    ({} mulf $data:expr) => { ... };
    ({} MULF $data:expr) => { ... };
    ({} mulf) => { ... };
    ({} MULF) => { ... };
    ({} divf $data:expr) => { ... };
    ({} DIVF $data:expr) => { ... };
    ({} divf) => { ... };
    ({} DIVF) => { ... };
    ({} modf $data:expr) => { ... };
    ({} MODF $data:expr) => { ... };
    ({} modf) => { ... };
    ({} MODF) => { ... };
    ({} stackalloc $data:expr) => { ... };
    ({} STACKALLOC $data:expr) => { ... };
    ({} stackalloc) => { ... };
    ({} STACKALLOC) => { ... };
    ({} stackdealloc $data:expr) => { ... };
    ({} STACKDEALLOC $data:expr) => { ... };
    ({} stackdealloc) => { ... };
    ({} STACKDEALLOC) => { ... };
    ({} push $data:expr) => { ... };
    ({} PUSH $data:expr) => { ... };
    ({} push) => { ... };
    ({} PUSH) => { ... };
    ({} pushi $data:expr) => { ... };
    ({} PUSHI $data:expr) => { ... };
    ({} pushi) => { ... };
    ({} PUSHI) => { ... };
    ({} pop $data:expr) => { ... };
    ({} POP $data:expr) => { ... };
    ({} pop) => { ... };
    ({} POP) => { ... };
    ({} popa) => { ... };
    ({} POPA) => { ... };
    ({} pusha) => { ... };
    ({} PUSHA) => { ... };
    ({} popb) => { ... };
    ({} POPB) => { ... };
    ({} pushb) => { ... };
    ({} PUSHB) => { ... };
    ({} popl) => { ... };
    ({} POPL) => { ... };
    ({} pushl) => { ... };
    ({} PUSHL) => { ... };
    ({} popf) => { ... };
    ({} POPF) => { ... };
    ({} pushf) => { ... };
    ({} PUSHF) => { ... };
    ({} popch) => { ... };
    ({} POPCH) => { ... };
    ({} pushch) => { ... };
    ({} PUSHCH) => { ... };
    ({} popnum) => { ... };
    ({} POPNUM) => { ... };
    ({} pushnum) => { ... };
    ({} PUSHNUM) => { ... };
    ({} popep) => { ... };
    ({} POPEP) => { ... };
    ({} zpopep) => { ... };
    ({} ZPOPEP) => { ... };
    ({} ppopep) => { ... };
    ({} PPOPEP) => { ... };
    ({} npopep) => { ... };
    ({} NPOPEP) => { ... };
    ({} fpopep) => { ... };
    ({} FPOPEP) => { ... };
    ({} dpopep) => { ... };
    ({} DPOPEP) => { ... };
    ({} getchar) => { ... };
    ({} GETCHAR) => { ... };
    ({} getline) => { ... };
    ({} GETLINE) => { ... };
    ({} writechar) => { ... };
    ({} WRITECHAR) => { ... };
    ({} writelineß) => { ... };
    ({} WRITELINEß) => { ... };
    ({} writeline $data:expr) => { ... };
    ({} WRITELINE $data:expr) => { ... };
    ({} writeline) => { ... };
    ({} WRITELINE) => { ... };
    ({} toggledebug) => { ... };
    ({} TOGGLEDEBUG) => { ... };
    ({} debugmachinestate) => { ... };
    ({} DEBUGMACHINESTATE) => { ... };
    ({} debugmachinestatecompact) => { ... };
    ({} DEBUGMACHINESTATECOMPACT) => { ... };
    ({} debugmemoryregion $data0:expr, $data1:expr) => { ... };
    ({} DEBUGMEMORYREGION $data0:expr, $data1:expr) => { ... };
    ({} debugmemoryregion) => { ... };
    ({} DEBUGMEMORYREGION) => { ... };
    ({} debugmemoryregion $data:expr) => { ... };
    ({} DEBUGMEMORYREGION $data:expr) => { ... };
    ({} debugstackregion $data0:expr, $data1:expr) => { ... };
    ({} DEBUGSTACKREGION $data0:expr, $data1:expr) => { ... };
    ({} debugstackregion) => { ... };
    ({} DEBUGSTACKREGION) => { ... };
    ({} debugstackregion $data:expr) => { ... };
    ({} DEBUGSTACKREGION $data:expr) => { ... };
    ({} $($trash:tt)*) => { ... };
    ($($($n:literal:)? $name:ident $($value:expr),*);* $(;)?) => { ... };
}
Expand description

Assembly compiler for esoteric VM.

Input format: <n>: <inst> <arg1?>, <arg2?>;, with:

  • <n>: being an optional helper prefix (usually an integer to denote he instruction’s location in memory),\
  • <inst> being the instruction, and \
  • <argx> being the argument (usually a number).

§Examples


let mut machine = Machine::default();

let assembly = esoteric_assembly!{
    // you can prefix the instruction with an integer
    // and use it to know where instructions are in memory,
    // but it's not checked so be careful.
    0: pushi 10;
    2: pushi 25;

    // you can omit the prefix
    popl;

    // you can set the prefix to an arbitrary amount
    1_000_000: Ωtheendisnear;
    // you can use any literal as the prefix
    "hello": ΩSKIPTOTHECHASE;
};

machine.load(&assembly, 0);