3 ms·
Looks like the default Lost Kingdom BF interpreter uses 8-bit cells, whereas the bf2wasm compiler uses 32-bit cells. This matters in Brainfuck; choosing the "wr
by swolchok 9y ago
Looks like the default Lost Kingdom BF interpreter uses 8-bit cells, whereas the bf2wasm compiler uses 32-bit cells. This matters in Brainfuck; choosing the "wrong" one of the idioms [-] and [+] for zeroing a cell gets worse as cells get bigger. Maybe if you tweaked the bf2wasm compiler to use 8-bit cells?
- swolchok 9y agoMoreover, the Lost Kingdom interpreter will expand the memory arbitrarily as it encounters > instructions, whereas the bf2wasm interpreter has a fixed limit of 16384 4-byte cells according to its documentation.
- lifthrasiir 9y agoOh, you are right; I simply overlooked that part of the readme. In my opinion that should have been 8-bit cells mainly because AFAIK simulating 16-bit or 32-bit in 8-bit cells is reasonable [1] but doing the other way without slowing it down too much is highly dependent to the program. [1] https://esolangs.org/wiki/Brainfuck_bitwidth_conversions https://esolangs.org/wiki/Brainfuck_bitwidth_conversions
- verdie-g 9y agoI didn't know about the idiom of using [+] for zeroing. Are the cells supposed to be signed ?
- Doxin 9y agoSignedness depends on your interpreter. In practice it hardly matters since there's no print function anyways, so if you want 2s complement you'll end up implementing it yourself anyways. [+] should always overflow to 0 at some point, which is entirely doable for 8 bit, but less so for 32bit. as for choosing between [-] and [+] you'll just have to guesstimate if 0 or intmax is on average closer to your value.
- MaulingMonkey 9y ago> This matters in Brainfuck; choosing the "wrong" one of the idioms [-] and [+] for zeroing a cell gets worse as cells get bigger. Translating these idioms to "*data = 0" was one of the first peephole optimizations I implemented when writing my own optimizing brainfuck interpreter.