2021-11-05 03:03:35 ttmrichter-M: What's an embedded platform people use that's not 8-bit bytes? 2021-11-05 08:07:23 veltas: TI C55x is a DSP w/16-bit bytes 2021-11-05 09:09:58 i think TI's 2800/picolo thing is the 12 bit one i was thinking of 2021-11-05 13:07:04 hi 2021-11-05 14:22:57 ugh. 2021-11-05 14:23:04 I'm locked in an analysis paralysis loop. 2021-11-05 14:32:08 so I have this reeeeally tiny language that operates on bits. and I've worked out how to formulate common control flow structures, the only thing I'm missing is how to encode data. the first "real" step is numbers. 2021-11-05 14:33:38 it's a time/space tradeoff between code and data. you can encode numbers as fixed-sized chunks of N bits, but you'll end up bloating your code, as you have to do something akin to `if this bit is 1, move to the next bit, , else, , end` for every bit. 2021-11-05 14:35:53 you can encode numbers as their representative digits and delimit the ends of them. this allows for arbitrary precision integers, at the cost of bloatingt he number representation, but with the upside that your code is smaller and more generic. 2021-11-05 14:37:15 adding two numbers together, for example, has a constant-sized code overhead for variable-length numbers, and this is less than the equivalent fixed-sized version. if you go fixed-sized, you save on data, but you bloat your code. if you go variable, you save on code, but you bloat your data. 2021-11-05 14:37:53 on top of that, you need other things like markers, sentinel values that delimit sections of things that you can easily scan for/match. 2021-11-05 14:38:24 surely you have this backwards? 2021-11-05 14:38:44 elaborate? 2021-11-05 14:39:24 if variable sized numbers makes your data bigger what is the point of using them? 2021-11-05 14:39:31 code bloat. 2021-11-05 14:40:39 maybe you are making your fixed sized registers needlessly complicated? 2021-11-05 14:40:50 there are no registers. 2021-11-05 14:41:07 the whole thing operates on a giant deque of bits. 2021-11-05 14:41:30 so encoding a number is basically finding a way to say "this chunk of the deque represents a number". 2021-11-05 14:41:57 okay. i was just using the word 'register' to refer to that chunk. 2021-11-05 14:42:47 if you have two fixed size chunks, 32 bits... you will probably get faster performance in software if you just consistently add 32 bits and do all the carries every time rather than doing a bunch of conditionals to see if you're done. 2021-11-05 14:43:02 again.. the language only works on bits. 2021-11-05 14:43:09 it'd help if I made that clearer. 2021-11-05 14:43:12 there are six instructions. 2021-11-05 14:43:14 []<>10 2021-11-05 14:44:01 https://www.toptal.com/developers/hastebin/raw/asuzivafet 2021-11-05 14:44:54 [ dequeues a bit, if it's 1, proceed to the next instruction. if it's 0, skip to the matching ]. < and > roll the deque left and right (taking a bit from the end, putting it on the head, etc.), 1 and 0 enqueue bits. 2021-11-05 14:45:10 I can't do bit operations in parallel. 2021-11-05 14:46:31 neat. 2021-11-05 14:47:50 when you're working at this level you just get caught in dumb traps of "how do I make a number". 2021-11-05 14:48:18 so what's the plan for adding two numbers? 2021-11-05 14:49:13 there are two approaches, one taking longer than the other, but I'm not sure of the code density yet. 2021-11-05 14:50:01 if I give you two fixed sized chunks of N bits and asked you to add them, you could just do the stupid thing by decrementing from one chunk, incrementing the other chunk, while the one you're decrementing != 0. 2021-11-05 14:50:24 that takes M steps, where M is the decimal value of the chunk you're decrementing. 2021-11-05 14:50:36 you then just drop that chunk of all zeroes. 2021-11-05 14:50:38 do you have a bunch of these deques, or is it always just one? 2021-11-05 14:50:42 just one. 2021-11-05 14:51:09 you can think of it as a tape that you can insert bits in at any point. 2021-11-05 14:51:15 the underlying implementation is just a circular buffer. 2021-11-05 14:52:40 you could _also_ actually encode binary addition. so, say, move to the end of one chunk, sample a bit, move back to the end of the other chunk, sample a bit, and then decide whether you carry. and if you carry, that's one branch, and if you don't, that's the other branch. 2021-11-05 14:52:54 repeat 8 times. 2021-11-05 14:53:14 you could end up with a giant operation of like 10k instructions or more. 2021-11-05 14:53:18 but it would be _faster_. 2021-11-05 14:53:38 i get it. 2021-11-05 14:54:44 you could also take each bit from a, add it to b in the appropriate spot, and rewrite a with the carry bit... then keep doing that until a is empty (no more carries) 2021-11-05 14:55:02 a=0 i mean 2021-11-05 14:55:56 soooo something like.. 00000001 00000011 -> 00000010 00000010 ? 2021-11-05 14:56:02 as a 'step'? 2021-11-05 14:56:27 that sounds like "decrement a, increment b". 2021-11-05 14:56:33 "while a != 0" 2021-11-05 14:56:43 hang on. 2021-11-05 14:57:04 re your general question about analysis paralysis: it sounds like you don't have enough information/experience to make good choices yet. so consider thinking of it as experiments. implement both ways and write up the results. 2021-11-05 14:58:04 I think it's also a form of scope creep paralysis, where I have to balance a couple dozen things, and that's difficult on its own. 2021-11-05 14:58:25 experiments grow in their cost from a single implementation to "I made this decision, therefore these branches change too". 2021-11-05 14:59:38 how I encode numbers influences how I encode a bunch of other things, from strings, to markers, to lists. 2021-11-05 15:00:12 we take for granted how many choices are made for us on actual hardware. 2021-11-05 15:02:35 add(a,b): while(a!=0){ c=(a&b)<<1; b^=a; a=c } / where ^ is xor, & is AND, << is shift left 2021-11-05 15:03:04 interesting, are you XORing the whole number there. 2021-11-05 15:03:05 (but you don't actually have a c, you just rewrite each bit of a to a&b after you use it, and then shift at the end.) 2021-11-05 15:03:42 yes hang on i made a whole video about turning addition into a boolean expression a while back. 2021-11-05 15:03:45 remember, whole-bit operations are expensive. `xor`ing a number still means we have to traverse the number. 2021-11-05 15:03:52 err, whole-number. 2021-11-05 15:04:05 same with ANDing, shifting, even checking for zero. 2021-11-05 15:04:45 https://www.youtube.com/watch?v=gtEGiq04E4Q 2021-11-05 15:04:51 the nature of the beast also means we consume bits as we conditionally match against them. 2021-11-05 15:05:11 oh neat. 2021-11-05 15:05:42 yeah. i don't know. you've got your work cut out for you no matter what you do. :) 2021-11-05 15:06:06 yeah... at some point, I think, you hit the simplicity barrier. 2021-11-05 15:06:34 where all choices are valid, but the blowup is exponential. 2021-11-05 15:06:42 maybe make a meta-language while you experiment, so you can write primitives like (a b xor) and have it compile down to the corresponding nano-language. 2021-11-05 15:07:02 that's what that little snippet earlier did. 2021-11-05 15:07:28 https://www.toptal.com/developers/hastebin/ukeqomumiy.py 2021-11-05 15:07:28 then you can just write words in terms of other words to build up, and experiment with changing one low-level definition at a time. 2021-11-05 15:11:26 yeah, this needs more top down than bottom up thinking. 2021-11-05 15:11:27 is the is like binary brainf*ck? 2021-11-05 15:11:30 ACTION struggles to put what he's thinking into words... 2021-11-05 15:11:36 *this 2021-11-05 15:11:49 MrMobius: pretty much, only based around a dynamic tape instead of a static one. 2021-11-05 15:11:58 saves you from moving data around and you can treat it like a stack naively. 2021-11-05 15:12:12 brb. 2021-11-05 15:12:16 just for fun? 2021-11-05 15:12:53 kinda? 2021-11-05 15:13:37 are you going to implement it in hardware? 2021-11-05 15:14:52 i get what you're doing with the python thing, but i was thinking a forth-like language because we're in #forth, and i actually think a forthlike macro syntax would be a much more useful tool for your situation. 2021-11-05 15:15:55 I agree, and that's what I'm trying to build up to. (on mobile phone) 2021-11-05 15:16:58 The machine model lends itself well to a forth macrolang. 2021-11-05 15:18:31 wait.. kronk are you the same person as imode? :) 2021-11-05 15:19:17 Yup! 2021-11-05 15:19:32 Just on my bouncer for mobile. 2021-11-05 15:20:43 maybe i should set up a bouncer...i just use remote desktop to log into an old PC i keep running with IRC. works the same from my phone or laptop 2021-11-05 15:21:14 its also wonderful to have a full web browser to use when the one on my cheap phone shits the bed 2021-11-05 15:21:15 i just ssh into an always-on box and never leave my house :D 2021-11-05 15:25:57 can this 6-operation machine perform an infinite loop? it seems like your instruction pointer can only ever move forward, which is part of your code bloat. 2021-11-05 15:26:26 you need a backwards jump if you want a universal computer. 2021-11-05 15:27:39 annnd back. 2021-11-05 15:27:52 yeah you can do an infinite loop. 2021-11-05 15:28:02 [1<] 2021-11-05 15:28:10 [ ... 1<] 2021-11-05 15:28:45 that translates, roughly, to, while(condition) { while(1) { ... } } 2021-11-05 15:28:46 what does ] do? 2021-11-05 15:28:51 jumps back to the matching [ 2021-11-05 15:28:54 unconditionally. 2021-11-05 15:29:26 ah okay you didn't define that earlier :) 2021-11-05 15:29:37 ahhh sorry. 2021-11-05 15:30:10 if you wanted true equivalence to while(1) it'd be 1<[ ... 1<] 2021-11-05 15:30:32 meaning "enqueue a 1 bit, bring it to the queue's head, loop while the top bit is 1", and inside the loop you just keep bringing a 1 to the head of the queue at the end. 2021-11-05 15:31:48 dropping a bit looks like [0<] 2021-11-05 15:32:01 a single-cased `if` looks like [ ... 0<] 2021-11-05 15:32:18 cool. well in any case, if it were me, i'd stop worrying about data modelling for a while, write a forthlike macro system, and then experiment with different combinations of definitions of the same words. 2021-11-05 15:32:49 if/else looks like 1[<[0<] ..true.. 00<]<[ ..false.. 0<] 2021-11-05 15:33:11 yeah.. I actually have a preprocessor for that that I could dig up, but it makes some assumptions about another language with a similar style/syntax. 2021-11-05 15:34:23 where the number 100, for example, was the command sequence ".64": . meant "push a 0", and hex digits 0 through F meant "shift this 4-byte constant into the number on the top of the stack". 2021-11-05 15:34:51 easy way to avoid treating your definitions as homogenous. 2021-11-05 15:35:05 err, not 4-byte, 4-bit. 2021-11-05 15:35:31 and heterogenous, not homogenous. 2021-11-05 15:35:48 your literals are literally sequences of code to construct those literals.