Daemon Silverstein<p><b>Using <a href="https://calckey.world/tags/GNU" rel="nofollow noopener" target="_blank">#GNU</a> <code>as</code> Assembler (not Assembly, but <i>the</i> Assembler) and <code>ld</code> Linker to spit out a working BMP gradient image. </b><span><br><br>Yeah, you read it right. I'm not using </span><a href="https://calckey.world/tags/Assembly" rel="nofollow noopener" target="_blank">#Assembly</a><span> to produce an image. I'm, instead, using Assembler directives and macros during compile-time to generate a binary file that happens to be a valid image (BMP) file.<br><br></span><b>File: tonishing.s</b><span> (GNU Assembly file)<br></span></p><pre><code>width = 320
height = 240
area = width * height
_begin:
.ascii "BM"
.int fileSize
.int 0
.int (_rasterdata - .)
_infoheader:
.int infoheaderSize
.int width # width
.int height # height
.short 1 # planes
.short 24 # bitcount
.int 0 # compression
.int 0 # imagesize
.int 11811 # xpixperm
.int 11811 # ypixperm
.int 0 # colorsused
.int 0 # colorsimp
infoheaderSize = (. - _infoheader)
_rasterdata:
n=area+1
.rept height
.rept width
byten=((n*255)/area)&0xFF
rn=(192*byten)/255
gn=(64*byten)/255
bn=(128*byten)/255
.byte rn,gn,bn
n=(n-1)
.endr
.endr
fileSize = (. - _begin)</code></pre><span><br></span><b>File: run.sh (Shellscript)</b><pre><code>#!/bin/sh
clear
rm astonishing.bin
rm tonishing.o
as tonishing.s --64 -o tonishing.o
# The pun is _astonishingly_ intended.
strip -R .comment -R .note.gnu.property tonishing.o
ld -n -x -s -N --oformat binary --unique=.note.gnu.property -o astonishing.bin tonishing.o
magick identify -verbose astonishing.bin</code></pre>I run the whole thing with... wait for it... <a href="https://calckey.world/tags/nodemon" rel="nofollow noopener" target="_blank">#nodemon</a><span>!<br><br>That's right: the tool intended for </span><a href="https://calckey.world/tags/Nodejs" rel="nofollow noopener" target="_blank">#Nodejs</a><span> hot-reloading, is being leveraged for GNU Assembly, which is itself being leveraged for compile-time instructions to produce a whole BMP image.<br></span><pre><code>nodemon -e "s sh" --exec ./run.sh</code></pre><span><br>While I have a </span><a href="https://calckey.world/tags/Codeberg" rel="nofollow noopener" target="_blank">#Codeberg</a> account, it's under my personal name where I published old projects from <a href="https://calckey.world/tags/GitHub" rel="nofollow noopener" target="_blank">#GitHub</a><span>, so I should do a second account for this pseudonym... but I'm not sure if this is against the Codeberg rules... So I'm posting the whole thing through a Calckey post instead.<br><br></span><a href="https://calckey.world/tags/programming" rel="nofollow noopener" target="_blank">#programming</a> <a href="https://calckey.world/tags/devlog" rel="nofollow noopener" target="_blank">#devlog</a> <a href="https://calckey.world/tags/dev" rel="nofollow noopener" target="_blank">#dev</a> <a href="https://calckey.world/tags/devhacks" rel="nofollow noopener" target="_blank">#devhacks</a> <a href="https://calckey.world/tags/quirks" rel="nofollow noopener" target="_blank">#quirks</a> <a href="https://calckey.world/tags/codegolf" rel="nofollow noopener" target="_blank">#codegolf</a> <a href="https://calckey.world/tags/experiments" rel="nofollow noopener" target="_blank">#experiments</a> <a href="https://calckey.world/tags/surreal" rel="nofollow noopener" target="_blank">#surreal</a> <a href="https://calckey.world/tags/absurd" rel="nofollow noopener" target="_blank">#absurd</a><p></p>