4,965 karma · joined October 31, 2013
Gap buffer was appealing on really slow machines, where you are counting cycles on each key-press. If the gap is at the right position, the cycle count is very low. But you can probably do the same even with a tree-structure: you need to keep a pointer to the leaf in the abstract pointer used for the cursor.
Also I would tie in the undo system to the data structure if possible. Rope does this with copy-on-write. Every version of the file could be a different top-node, and most middle and leaf nodes would be shared between revisions.
BTW, with any of these tree-based structures (like rope) you can store other meta-data in the the headers to make a fast index. For example, I would put a newline count in the rope headers, to make find a particular line a fast operation.
https://sourceforge.net/p/joe-editor/mercurial/ci/default/tr...
Also: read Rule 34 by Charles Stross. The weirdest thing about this book is that it's written in 2nd person.
Crazy, DNA uses this trick!
"-Os" should search for possibilities here..
I'm wondering if such code breaks any CPUs. I could imagine that it could confuse the code translation that modern x86s do. I mean I bet they don't test this particular corner case...
How can I have strict type checking, but a user defined format string?
https://www.transmissionzero.co.uk/computing/win32-apps-with...
I used it to make an application that downloads files over a serial port from an OptiCon bar-code scanner:
https://github.com/jhallen/cartscan
Coming from UNIX, the biggest annoyance was Microsoft's use of wide character strings.
https://www.belmont-ma.gov/dpw-water-division/faq/what-is-th...
You can detect carry of (a+b) in C branch-free with: ((a&b) | ((a|b) & ~(a+b))) >> 31
So 64-bit add in C is:
f_low = a_low + b_low
c_high = ((a_low & b_low) | ((a_low | b_low) & ~f_low)) >> 31
f_high = a_high + b_high + c_high
So for RISC-V in gcc 8.2.0 with -O2 -S -c add a1,a3,a2
or a5,a3,a2
not a7,a1
and a5,a5,a7
and a3,a3,a2
or a5,a5,a3
srli a5,a5,31
add a4,a4,a6
add a4,a4,a5
But for ARM I get (with gcc 9.3.1): add ip, r2, r1
orr r3, r2, r1
and r1, r1, r2
bic r3, r3, ip
orr r3, r3, r1
lsr r3, r3, #31
add r2, r2, lr
add r2, r2, r3
It's shorter because ARM has bic. Neither one figures out to use carry related instructions.Ah! But! There is a gcc macro: __builtin_uadd_overflow() that replaces the first two C lines above: c_high = __builtin_uadd_overflow(a_low, b_low, &f_low);
So with this:
RISC-V:
add a3,a4,a3
sltu a4,a3,a4
add a5,a5,a2
add a5,a5,a4
ARM: adds r2, r3, r2
movcs r1, #1
movcc r1, #0
add r3, r3, ip
add r3, r3, r1
RISC-V is faster..EDIT: CLANG has one better: __builtin_addc().
f_low = __builtin_addcl(a_low, b_low, 0, &c);
f_high = __builtin_addcl(a_high, b_high, c, &junk);
x86: addl 8(%rdi), %eax
adcl 4(%rdi), %ecx
ARM: adds w8, w8, w10
add w9, w11, w9
cinc w9, w9, hs
RISC-V: add a1, a4, a5
add a6, a2, a3
sltu a2, a2, a3
add a6, a6, a2Also it's a business opportunity along the lines of the star name registry.
Maybe if IBM chose 68K for the PC, we would have gotten the full blown PL/I.
Edit, well actually I found this "X3.74, PL/I General Purpose Subset (Subset G)" from 1983. This version at least has strings.
Look at manual disk here:
https://winworldpc.com/product/digital-research-pl-i-compile...
Otherwise the Arduinos with USB are a convenient way to connect I2C to a PC..
https://github.com/jhallen/joes-sandbox/tree/master/hw/lined...
CAN is interesting in that the protocol is pretty complex, but from software point of view it's just send_packet() and register a handler for receive packets. The annoying thing is that MCUs don't have built-in CAN line drivers.
A new thing is 1000BASE-T1- Gigabit Ethernet over a single twisted pair. This is supposed to be the future in the auto world..
This is not true of I2C, where the slave could stretch the clock forever.
This is also not true of UART, where the slave just might not respond. But in fact both SPI and I2C can be simpler than UART since they are strictly master/slave. With a UART, the slave could send you unrequested data, which means your software has to handle asynchronous events. Even if it doesn't you probably have to implement timeouts and input flushing.
SPI is simpler than I2C in that it is a single-master bus, so accesses are atomic (at least at the bus level, within your RTOS is another story...).
You can use simple logic gates as SPI peripherals: for example, 74HC595 works as a SPI accessible 8-bit output port. This is important because such chips are the cheapest available (vs. I2C output port or UART to parallel..)
Despite all this simplicity, SPI is very fast.
Where UART has the advantage is software: picocom on Linux or Teraterm on Windows. Basically you don't have to develop any host-side software if you use a UART. I like to use the old ymodem protocol for embedded system firmware updates.. since again no host-side software has to be developed.
https://stackoverflow.com/questions/1976007/what-characters-...
http://www.trs-80.org/was-the-trs-80-once-the-top-selling-co...
https://www.youtube.com/watch?v=0d0MPg7DxbY
But liquid fuels are incredibly convenient, so maybe they will be worth the high price in certain applications. For example in jet engines for airplanes.
https://electrek.co/2021/09/27/the-worlds-longest-subsea-cab...
The problem for doing this large scale if the right of way for the HVDC lines. I'm watching this on a smaller scale in Massachusetts, where Maine voters are blocking a HVDC link to Hydro Quebec. But I think this is a game between established interests.. in this case NextEra funded the ballot question and advertising, I think because they lost out on their SeaLink project (HVDC to Seabrook nuclear power plant).
https://www.energy.gov/sites/prod/files/2020/09/f79/EXHIBIT%...
https://www.newscentermaine.com/article/news/politics/refere...
So this is my amended problem: convert the tree to a same-ordered doubly-linked list without using recursion or an explicit stack.
https://en.wikipedia.org/wiki/EDIF
At least for netlists, it is a popular format.
I've not tried Altium's autoplacer, but its autorouter is crap. I bought into PADS in the 90s (it was better than Protel, but not as expensive as OrCAD PCB). It used Specctra and then their own Blaze router. Both were excellent. I can not believe how bad Altium's autorouter still is (it leaves your board full of drc errors including shorts).
It is difficult to convey how well auto-routers can work to people who are used to manually routing boards in Altium because of it's broken auto-router. Seriously you hit the auto-route button, and a few minutes later it's done. You do want to ensure you have good constraints, all of the work is there, and it's a good idea to have them even when manually routing. It's very feasible to move parts around and do trial full routes to help find the best placement.
PADS did have an autoplacer, but it did not work very well as I remember.