View on GitHub

Quorten Blog 1

First blog for all Quorten's blog-like writings

What exactly is the stack?

2018-06-02

Categories: unlipic  
Tags: tour-de-force   unlipic  

What exactly is meant by the “stack”? Well, when writing computer programs, a “stack” is a useful data structure to use in general. However, for modern compilers and hardware architectures, the hardware stack has a special use and meaning.

The hardware stack should only be used for the following:

  • Storing subroutine return addresses

  • Storing local variables for the particular subroutine

  • Passing in variables and returning variables from subroutines

  • Handling interrupts and exceptions

For any other memory allocation pattern that does not meet these constraints, the data must instead be placed elsewhere in memory. Typically, all other such memory allocations are handled by a memory allocation manager called the heap.

In conventional programming languages, the stack is at the highest memory address and the heap is at the lowest memory address. (That is, the highest and lowest addresses available for user code, not reserved by the operating system.) The stack grows down toward lower memory addresses, and the goal of a heap memory manager is to keep the whole collection relatively contiguous and grow upward toward higher memory addresses. In theory, this allows for the most optimal use of available memory by any program. In practice, the stack has an arbitrary limit set in advance such that it cannot grow all the way to the limit of the heap.

  • Footnote: Although it is possible to allocate variable-sized data on the stack, this is strongly discouraged in modern-day computer architectures. Why? When only fixed-sized variables are allocated on the stack, it is possible to compute the address of any stack local variable by adding a constant to the address of the top of the stack. But, if those items are of variable-size, you need to keep track of another variable, the base pointer, in order to locate variables on the stack. Finally, the variable-sized data has a fixed-size pointer that is stored near the top of the stack. The point is that with allowing a variable-sized stack, you get one less CPU register to work with, which slows down code in the common case.

Okay, so this is an interesting thing to think about. The Apple II monitor program is a great “application” of its own in many ways. Why not implement it as a standalone “application” on modern platforms? Well, come to think about it, the Apple II monitor isn’t unique in its own. MS-DOS debug provides a very similar concept, but implemented in a “more modern” manner and with some nice new features, like assembling from user input. Plus, it probably had a larger historic user base, so searching for modern Linux-like alternatives to it may be easier.

Okay, so let’s do exactly that. On first sights, it seems that people are recommending GDB for this purpuse, but upon closer inspection of GDB, it unfortunately doesn’t appear to have the feature of assembling from user input. So, it’s like as good as the Apple II monitor, but not as good as MS-DOS debug.

Read on →

Okay, so playing around with WebAssembly. I want to compile more sophisticated command-line applications to run in the browser, but the default WebAssembly shell isn’t good enough. So, what are my options? Well, there are some JavaScript terminal emulators that can be put up as front-ends to your WebAssembly. Er, well, Asm.js at the moment due to a glitch between the Fetch API and WebAssembly output as of today.

20180602/https://stackoverflow.com/questions/48292269/how-can-i-run-an-interactive-program-compiled-with-emscripten-in-a-web-page
20180602/https://gist.github.com/jcubic/87f2b4c5ef567be43796e179ca08c0da
20180602/DuckDuckGo emscripten fetch
20180602/https://kripken.github.io/emscripten-site/docs/api_reference/fetch.html
20180602/DuckDuckGo FETCH not yet compatible with wasm (shared.make_fetch_worker is asm.js-specific)
20180602/https://www.mail-archive.com/emscripten-discuss@googlegroups.com/msg07288.html

Oh, and to mention this while we’re at it, WebAssembly output is now the default! No need to switch it on anymore.

Finally, since the Fetch API is asynchronous, you need to setup some “cothreads” to use it in larger programs that expect a synchronous API.

So, yes we do have projects that emerged, I believe starting from the Docker community, that use this standard contributor covenant for open-source projects.

Also, the introductory text on the site links to some interesting articles. Meritocracy is, in fact, a bad idea as a means to explain why things are “going well” in the open-source community.

20180601/https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
20180601/https://www.contributor-covenant.org
20180601/https://modelviewculture.com/pieces/the-dehumanizing-myth-of-the-meritocracy
20180601/https://modelviewculture.com/pieces/getting-started-in-techs-social-justice-movement

This article has some interesting ideas in it, but I’d warn it may not be as enjoyable of a read as the others.

20180601/https://modelviewculture.com/pieces/beauty-as-safety-why-feministsareugly-is-more-than-meets-the-eye

So, it turns out that the decision on Banana Pi is a more complicated one. At second sight, it looks like Orange Pi might be better because the prices are lower. However, it turns out that Orange Pi has a host of hardware problems of it own. Even the later Banana Pi models have a host of hardware problems. The very earliest Banana Pi models are really the only ones you would want to get.

And wait, there were signs of legal issues? Well, no, looks like it was just a legal dispute. However, there is a Realtek development board chipset that is problematic, it looks like. However, I believe that is not related to the Allwinner.

Read on →

Okay, so I think I’ve figured out how to get my categories and tags index pages to display the titles and subtitles to my liking. It is possible to do this by looping through all the site’s pages. There, you will have access to each page’s front matter variables, which you can then use to render your list items with titles and subtitles. The nifty trick of including a page to get it to render using a “layout” that specifies merely a list item, well I couldn’t get that to work due to the front matter getting included verbatim rather than being parsed out.

For larger sites, you are recommended to use collections so that you can narrow down looping to particular namespaces.

20180601/DuckDuckGo jekyll include page front matter
20180601/https://stackoverflow.com/questions/50246063/include-front-matter-from-another-md-file
20180601/https://jekyllrb.com/docs/datafiles/
20180601/https://jekyllrb.com/tutorials/navigation/#scenario-8-retrieving-items-based-on-front-matter-properties
20180601/https://jekyllrb.com/docs/collections/
20180601/https://jekyllrb.com/docs/variables/

Video! Why do we even have to think about communication in natural language? When our technology was more primitive, it was the only convenient way to communicate. Of course, now with video telecommunication technology, video communications can provide a much more convenient way of communicating, not subject to the symbolic incompatibility of hapticly evolved human natural languages.

Wouldn’t it be nice to be buddies and talk with someone from ancient times? There are some things that us moderners think considerable difficulties, namely traveling long distances on foot to get around, that surely someone from ancient times would laugh off our complaints as silly. Well, you don’t have to cross the time boundary, you can converse with people in less developed countries today, via smartphones. And machine translation? No, you don’t need that. With new advances in technology, there are by far less ambiguous, more compatible ways to communicate in the modern era, namely video.

So, you’re wondering, yes there is Thingiverse, but what are all the options for 3D print design file hosting and sharing? In particular, what are the more formidable alternatives to Thingiverse?

Well, well. Sure, I’ve known that GitHub has been an option for quite some time now, but this GitHub pages template makes it look even more competitive. There is a successor to this too, which is supported by the RepRap community.

20180531/DuckDuckGo github 3d print models versus thingiverse
20180531/https://www.reddit.com/r/3Dprinting/comments/26do2z/alternative_repositories_to_thingiverse/
20180531/https://traverseda.wordpress.com/2014/05/23/makerbot-blatently-steals-and-patents-a-community-design/
20180531/https://github.com/garyhodgson/githubiverse-template/
20180531/https://github.com/garyhodgson/thing-tracker-site-template
20180531/http://garyhodgson.com/reprap/2014/06/thing-tracker-site-template/

Alas, the fate of this Thing Tracker must be the same as the fate of FastCGI: With the main, official specification website no longer function, it must be obvious that the community has basically abandoned this as any form of standard. Sad but true. And, just like FastCGI, it was a great idea too… unfortunately this time through, I don’t think it is true to say that there are any successor technologies to replace this.

20180531/https://web.archive.org/web/20170920105558/http://thingtracker.net/

So, it appears that Kramdown doesn’t have support for automatically generating links for URLs in the text. That is unfortunate. The only way to handle this is through a Jekyll plugin, and for that to work, I would need to use another web service for CICD like Travis CI. For the time being, I want to refrain from using too many external site services and making things too complicated like that. Also, I want to keep the original Markdown clean so that it still makes sense to read on its own. My apologies for the inconvenience.

I’ve been thinking about adding support to Kramdown so that it can automatically generate such links, but looking at the design architecture of Kramdown, this might not make logical sense. So, plugin filter it shall be.

20180531/DuckDuckGo kramdown auto url link
20180531/DuckDuckGo kramdown generate url link automatically
20180531/https://github.com/shoyan/kramdown_easy_link

First of all, what are other people saying about GitHub pages for blogging on it? How many people are using it? Ah, some are not liking it! One person would rather host their own server due to complications.

20180531/DuckDuckGo github pages jekyll blog
20180531/https://gon.to/2015/03/03/f-percent-number-ck-github-pages-for-jekyll-why-i-decided-to-use-digital-ocean/

20180531/https://quorten.github.io
20180531/DuckDuckGo google sitemap.xml

This is an interesting website for automatically generating sitemaps. Alas, it is not necessary as some other sites that are well-indexed yet are still personal blogs do just fine without a sitemap.

20180531/https://www.xml-sitemaps.com
20180531/https://support.google.com/webmasters/answer/156184?hl=en