View on GitHub

Quorten Blog 1

First blog for all Quorten's blog-like writings

I went to an interesting Golang Meetup about running Lua in Golang and vice versa, these are the notes.

20200415/https://github.com/andreburgaud/meetup-golang-lua

Want to recompile code automatically during development of a server of a sort? modd is a great system to do this with Golang.

20200415/https://github.com/cortesi/modd

Also, another related subject. Can you get a “notebook-style” interface to Golang? Indeed you can, there are many options available if you search around, but the first one that comes up is Gophernotes. It actually works directly with Jupyter.

20200415/https://github.com/gopherdata/gophernotes

One thing that has been an ongoing challenge in the design of my 3D scanner software, well, almost any of my software in general I guess I could say, was the lack of good integer math library routines. Surely, there’s got to be good integer math library routines out there, I just need to search for them, right?

Well, that’s the catch. Yes, there are good integer math routines out there, but traditionally, you won’t find them in a nice standalone library.

Come on, think about the greatest software you know of that uses integer math extensively. Not just the basics, but integer arithmetic for higher level mathematics. The Doom and Quake game engines come to mind, along with the MPEG-2 audio/video codecs. How did they implement their integer math routines? Did they find them in a shared library? Nope, they wrote them all on their own. Did they even create a shared library of their own? Nope, they wrote them solely for the purpose of embedding in the Doom and Quake game engines. For the MPEG-2 audio/video codecs, although the audio/video interface is exposed as a shared library, the integer math routines are not. So the greatest integer math programmers did that, so you must do it yourself if you want great integer math for software of your own.

Read on →

Simple 8-bit CPU revisited

2020-04-13

Categories: unlipic  
Tags: unlipic  

In light of it being practical to eliminate of carry flags and shift instructions from a CPU architecture, how woiuld my simple 8-bit CPU instruction set architecture look like with similar modifications? This is it.

8-bit registers
Registers: A, B, BH (page #), PL, PH
Load-store architecture
Addressing modes: immediate, 16-bit memory, 8-bit memory from page #,
8-bit register indirect from page #

Read on →

Long integer arithmetic: When you compute with integers larger than a machine word, you typically need to use assembly language so that you can access the carry bits generated by the machine arithmetic instructions. But, RISC-V does not a have a carry bit? What, that changes everything. Okay, okay, if we do not need to make assumptions that the underlying hardware generates carry bits, then we might as well just do it all in C.

So, how do we generate a carry bit in software? All I’ve heard thus far is “it’s easy,” so let me try my own derivation, then I’ll see what I can find on the Internet more specifically.

Here is your function table:

Read on →

This is a great Digi-Key article on considerations for long-term IoT sensors.

20200412/https://www.digikey.com/en/articles/energy-harvesting-versus-batteries-for-multidecade-iot-sensor-operation

And… one thing in particular it covers in depth is the use of lithium thionyl chloride batteries. Oh, those monsters again, what could possibly be good about them? Despite their prospective risk for explosiveness at the end of their lives, they have among the lowest self-discharge rates of all battery chemistries. So, if you have a low-current application that you want running for several decades, lithium thionyl chloride batteries are the way to go. If you don’t mind the possibility of explosion and corrosive damage to your electronic device, that is.

Previously I’ve discussed a number of mathematical tricks with integer arithmetic and vectors, square roots, and systems and equations. Next up is a new challenge: How do you construct a table of logarithms using only integer arithmetic?

The first thing to master is the algebra of exponents, and logarithms, of course. Let’s do a brief review here.

x^a * x^b = x^(a + b)
x^a^b = x^(a * b)
sqrt(x) = x^(1/2)
sqrt(sqrt(x)) = x^(1/2)^1/2) = x^(1/2*1/2) = x^(1/4)

Okay, so that last equation is key. You might be wondering, “How do I compute the nth root of a number?” The answer is right there, in the rules of exponents. You can actually do just fine if you only have the square root operator implemented directly. Using the rules of exponents, you can constructively implement any other nth root or raising any number to a fractional power.

So, with that in place, here’s another question. Suppose you don’t have a table of logarithms, but you want to compute the logarithm of a number iteratively by multiplying or dividing. How do you do that? Remember these rules.

Read on →

This is a very interesting article about how mutations in the Coronavirus can be used to track its generational count and also what kinds of paths it may have taken for the disease transmission. Virus duplication is a sloppy and hasty process that produces errors. It turns out that the mass infections in New York have largely started coming from Europe, where travel was unrestricted, and also there was a cross-country source from Washington state.

20200409/https://www.nytimes.com/2020/04/08/science/new-york-coronavirus-cases-europe-genomes.html?referringSource=articleShare

This is a very insightful article about how Coronavirus can spread quite prolifically through social activities, and the corresponding importance of social distancing. Someone who only has mild symptoms and continues to be a prolific socialite can transmit the disease to others who it is fatal to.

20200409/https://www.washingtonpost.com/health/2020/04/08/funeral-birthday-party-hugs-covid-19/

QEMU shared clipboard

2020-04-09

Categories: unix  
Tags: unix  

How do you get a shared clipboard with QEMU? It’s easy with VMware and VirtualBox, just install the guest tools?

Here’s the trick with QEMU? There’s not just one set of guest tools, but three in total: QEMU guest tools, oVirt guest tools, and SPICE guest tools. If you only installed the first two, you’re not going to get the shared clipboard. Go download and install the SPICE guest tools to get the shared clipboard.

20200409/DuckDuckGo qemu windows shared clipboard
20200409/https://askubuntu.com/questions/858649/how-can-i-copypaste-from-the-host-to-a-kvm-guest
20200409/https://www.spice-space.org/download/windows/spice-guest-tools/spice-guest-tools-latest.exe
20200409/https://www.spice-space.org/download/binaries/spice-guest-tools/

Bridge networking to a VM… just set the network mode to this and your VM will be able to communicate with your host and larger network alike, right? On VMware and VirtualBox, yes, it works easy and nice like that. But, on QEMU, unfortunately things are more complicated. You can’t just click an option to set it up, if you do setup the easy default “bridged” option this will allow communication from the VM to the larger network, but not between the VM and the host. Why is this? Apparently, if you do setup bridged mode to a particular hardware interface, then this means that communications will go directly to that device completely bypassing the host operating system networking stack. If you want the host and guest to communicate one alike as if they were connected on the same network, you’ve got to setup a tup/tap bridge device and connect the guest machine there. And how do you do that?

Well, unfortunately this doesn’t look too easy, but there are ways. Looks like any way you choose will not play well with NetworkManager autoconfiguration and management. Yeah, sure, this works perfectly fine for the common use case where you are configuring a server sitting inside a datacenter, but if you are setting this up on a personal computer, gosh that’s a nuisance.

Read on →

Here is a great Digi-Key blog article about the futre of programmable logic design, and evaluating the problem that current programmable logic systems make programming more complicated than it should be for setting up simple logic circuits. It also introduces some existing software solutions that can simplify programmable logic design.

20200407/https://www.digikey.com/en/blog/the-next-generation-of-programmable-logic-developer

Also, another interesting fact that this article points out is that there are 8-bit microcontrollers are the majority of microcontrollers sold, both in customer count and in number of units sold.