Time Nick Message 00:30 cheapie 3336 lines of code to make a glowlight flash once per second has to be some kind of record 00:31 cheapie 3308 of that is Lua, the rest is RISC-V assembly 00:32 user333_ why do it in a simple way when you could do it like that? 00:33 cheapie FWIW this is the assembly part: https://gist.github.com/cheapie/45406dabdd7d031859caf6a1832a1675 00:33 * user333_ pretends to know RISC-V assembly 00:33 user333_ nice code 00:35 cheapie 1-4 set up the MMIO region and configure pins B and D as output (also turning the output on), 7-11 is hopefully self-explanatory, 12-13 waits for the blinky plant (on one of the other pins) to blink, 14 jumps back to 6 to restart the loop when it does 00:35 cheapie 17-19 load the current mesecons I/O values, toggle pins B and D, then write them back 00:36 user333_ ah 00:36 cheapie 25 does the sleeping between flashes (the ones where it's not waiting for the blinky plant), 26-27 make it run line 25 13 times (the 13 comes from line 23) before it returns 00:38 cheapie Lines 12-13 are the ones I'm most proud of - they're borrowed from my digital sign thing and are my favorite way to wait for a mesecons input to change on RVController, provided I don't care which input it is 00:39 user333_ i assume assembly becomes much easier once you know all the keywords 00:39 cheapie The lr.w on line 12 is a "load reserved" from Zalrsc (part of A), it basically means "read the data from this memory address and then keep an eye on it to see if anyone else changes it". Normally you would pair it with an sc.w (store conditional), which is "write this data to this memory address, but ONLY if nobody touched it since the lr.w" 00:39 cheapie yes 00:40 user333_ otherwise it just looks like little clumps of letters 00:40 cheapie In this case I'm instead pairing the lr.w with a wrs.nto (wait for reservation set, no timeout), which is from Zawrs and means "halt until someone touches the memory I did an lr.w on" 00:42 user333_ makes me respect the work C compilers do to translate easily human-readable code into lower-level assembly 00:43 cheapie Really even just knowing what the instruction abbreviations expand to helps a lot. li = load immediate, csrw = CSR write, sh = store halfword, call = (take a guess), lr.w = load-reserved word, wrs.nto = wait on reservation set, no timeout, j = jump, lb = load byte, xori = XOR with immediate, sb = store byte, ret = return, pause = ...pause, addi = add immediate, bnez = branch if not equal to zero 00:45 cheapie li, csrw, call, j, ret, and bnez there are pseudoinstructions, most likely expanding in this case to: lui+addi, csrrw, jal, jal, jalr, and bne respectively 00:46 user333_ is there any real reason that assembly uses such abbreviated keywords? 00:47 cheapie Less tedious to type is probably the big one at this point 00:47 user333_ true 00:48 user333_ though not many people write assembly these days (aside from very low level stuff) so it doesn't matter *too* much 00:48 cheapie Like I'd much rather type "sh t1,0(s0)" as opposed to "storeHalfWord(temporaryRegister1,savedRegister0,0)" 00:50 cheapie Modern amd64 has instruction names like "VCVTTPD2UQQ", I'd really hate to have to type the full name of _that_ out 00:51 user333_ reminds me of when i picked up writing bash (well, POSIX shell usually), lots of unintuitive things 00:53 * cheapie gives user333_ https://www.cs.sfu.ca/~ashriram/Courses/CS295/assets/notebooks/RISCV/RISCV_CARD.pdf 00:54 cheapie RVController is RV32IMACB and therefore supports every instruction in there except for the F/D stuff on page 2 (and therefore also the corresponding pseudoinstructions on page 4) 13:42 MinetestBot 02[git] 04CodingMantisUA -> 03luanti-org/luanti: HUD inventory: allow custom background per element (#17359) 13b4eb8b9 https://github.com/luanti-org/luanti/commit/b4eb8b91e611c3d83f7557c39b4f1caab9406e57 (152026-09-18T13:41:38Z) 16:12 * cheapie hmms at https://www.reddit.com/r/StVO/comments/1goslcm/motor_abstellen/ for a bit, makes https://cheapiesystems.com/media/images/screenshot_20260918_111129.png