Paolo Amoroso's Journal

Tech projects, hobby programming, and geeky thoughts of Paolo Amoroso

Bob Nystrom, a Google software engineer who works on the Go programming language, self-published two software development books, Game Programming Patterns and Crafting Compilers.

The books, available in digital format and in print, are deservingly popular. They cover interesting topics, provide clear explanations and code, are beautifully designed, and can be read online for free.

But the meta level is as interesting as the creative works themselves.

Bob posted to his blog a series of articles describing his tech book publishing process. These long and detailed posts are a fascinating read, a peek behind the curtain of running two complex tech writing projects.

The posts share every aspect of the work that went into the books.

The description of the custom-built toolchain and the workflow for formatting the Markdown manuscript is geeky. This involved combining the text and sample code, taming the arcane Adobe InDesign, and producing both the digital and print versions of the books.

Bob goes into a lot of detail also on his writing routine. For years he had the discipline to write every single day despite the stress of a demanding job, family life, personal tragedies, and setbacks.

Finally, the posts discuss the business and marketing side of the publishing projects. Bob reports on the book launches, the promotion strategy, and the early sales.

The experience of Bob, who declined a traditional publishing deal to go full indie, is a valuable resource for self-published technical authors.

#selfpublishing

Discuss... Email | Reply @amoroso@fosstodon.org

While reporting my challenging experience with picking a blogging platform, I incorrectly assumed Silvrback was unmaintained. I hadn't heard back from my email inquiry to them and the latest activity on their Twitter profile dated back to two years earlier.

Silvrback's founder, Kermit Kuehn, later reached out to me to confirm the platform is still maintained and supported.

I updated my previous post. I'm glad Silvrback is alive and I recommend checking it out. Although I'm happy with with my choice of Write.as, Silvrback was a close runner up.

#blogging

Discuss... Email | Reply @amoroso@fosstodon.org

Encouraged by the emuStudio developer, I donated to the project an Intel 8080 Assembly demo. It's a modified version of Twirl, my program to display a twirling bar animation.

Here's the code I contributed:

; Twirling bar animation by Paolo Amoroso <info@paoloamoroso.com>
;
; Runs on an Altair 8800 with an ADM-3A terminal. Press any key
; to interrupt the program.


FRAMES    equ  8              ; Number of animation frames

CLS       equ  1ah            ; ADM-3A escape sequence
HOME      equ  1eh            ; ADM-3A escape sequence
STATUS    equ  10h            ; Input status port
READY     equ  1              ; Character ready status mask


          mvi  a, CLS         ; Clear screen
          call putchar

loop:     lxi  h, ANIM        ; Initialize frame pointer...
          mvi  b, FRAMES      ; ...and count

loop1:    mvi  a, HOME        ; Go to home
          call putchar

          mov  a, m           ; Print current frame
          call putchar

          push psw
          in   STATUS
          ani  READY          ; Key pressed?
          jnz  exit           ; Yes
          pop  psw

          inx  h
          dcr  b
          jnz  loop1

          jmp  loop


exit:     pop psw             ; Clear psw left on stack
          hlt


ANIM:     db   '|/-\|/-\'     ; 8 frames


include	'include\putchar.inc'

Unlike the original code, which I designed to run on emuStudio and be easy to port to CP/M, this new version is intended to run only on emuStudio. This was an occasion to simplify the code.

The main difference is the escape codes for VT100-compatible terminals on CP/M are strings, whereas the ADM-3A codes Twirl sends on emuStudio are single bytes. This allows the program to print the codes with the putchar library subroutine instead of putstr. Doing away with putstr no longer requires saving and restoring the HL register pair in the calling sequences.

Finally, I added code to terminate the program if a key is pressed.

#intel8080 #Assembly

Discuss... Email | Reply @amoroso@fosstodon.org

I have fond memories of COHERENT, the first Unix system I could afford on my own PC. Its manual made me grok Unix and its philosophy.

Developed by Mark Williams Company, COHERENT was a clone of System 7 Unix that run on PCs with at least an 80286 CPU. The BYTE magazine ads of this $99.95 Unix, and what I read about the operating system, had intrigued me for the great value. The product was affordable even for a computer enthusiast and hobby programmer like me.

I bought COHERENT around 1991 and installed it on a 386 laptop with a 40 MB HD, reserving a 20 MB partition for COHERENT and the rest for DR-DOS.

I loved the product. COHERENT worked beautifully, was a lot of fun, and I used it daily for a couple of years. It was my first opportunity to explore Unix.

I loved COHERENT's manual too. I read it front-to-back several times and browsed it frequently. That thick book gave me the first comprehensive, clear, coherent (no pun intended) introduction to Unix.

I valued the manual so much because, back then, it was difficult to acquire technical books and software documentation in my country, Italy. I had only limited access to foreign mail-order vendors of technical publications.

COHERENT's manual had everything I wanted to know. I often browsed it just to serendipitously come across something interesting.

My favorite parts were the awk tutorial, which made me fall in love with the language, and the coverage of uucp, which unlocked my access to email. I got a modem and the COHERENT manual helped me set up uucp to read and send email with elm.

It was a joy to discover the full COHERENT manual is available online.

Robert Swartz, the founder of Mark Williams Company, gave permission to publish the document. Steve Ness, who was in charge of documentation in the very early days of COHERENT, reformatted and posted the manual. I got in touch with Steve to thank him for the many pleasant hours I spent with his work.

In the early 1990s I bought additional COHERENT software from Mark Williams Company, such as the device driver SDK and X Window, and possibly also Promula Fortran. I never got to use that software much, as the SDK was challenging and my PC didn't have enough RAM for X Window.

By then Linux was already too prominent not to notice. I eventually switched to Linux, which became my desktop operating system for the next couple of decades.

#retrocomputing

Discuss... Email | Reply @amoroso@fosstodon.org

Once I fixed the Suite8080 assembler to let db accept uppercase symbols, I was ready to work on a similar fix for dw.

But I got dw uppercase support for free as a side effect of canonicalizing symbols to lowercase when adding 16-bit words to the symbol table, as dw already converted symbols to lowercase before checking for inclusion in the table. This unlocked uppercase symbol support, again for free, for most other 8080 instructions that take an address operand such as lhld, shld, lda, sta, jmp, and more.

#Suite8080 #Python

Discuss... Email | Reply @amoroso@fosstodon.org

I resumed working on Suite8080 and fixed the assembler's db directive to accept uppercase symbols as in this example:

SYM		equ	1
label:  	db	SYM

I changed the code that adds symbols to the symbol table to canonicalize to lowercase, and the db processing code to convert symbols to lowercase before checking if they're in the table.

Suite8080 is a suite of Intel 8080 Assembly cross-development tools I'm writing in Python.

#Suite8080 #Python

Discuss... Email | Reply @amoroso@fosstodon.org

Google released a Gmail redesign that finally rolled out to me. Here are my first impressions after a few days.

What's new?

The redesign integrates the Gmail email client with Google Chat messaging and Google Meet video calling. The early feedback I read was from unhappy users who made it seem the sky was falling.

But I kind of like the refreshed look and don't mind the new layout.

Now i notice a new color palette, the toolbars framing the window sides have a different background shade, and there are a few more tweaks. The only major addition is a thin left sidebar with tabs for Gmail, Chat conversations and spaces, and Meet meetings.

The left sidebar does reduce horizontal space and leaves less room for the email subject and snippet in the inbox list view, especially on small screens such as those of Chromebooks. But there's still enough context and on the 1080p monitor of my daily desktop driver, an ASUS Chromebox 3, the extra sidebar space is not an issue.

The new layout comes with some handy extra funcionality. For example, the Chat notification badges for incoming messages, and the lists of conversations and spaces that pop up when hovering over the Chat icons. This may make redundant the separate Chat window I usually keep open.

Too bad Google Chat is not even a blip on the radar of the messaging market and I have so few contacts left on Chat.

#Google

Discuss... Email | Reply @amoroso@fosstodon.org

Is Write.as usable on mobile?

Let's find out. I'm writing this with the Write.as plain text editor in Chrome on a Pixel 4 XL Android phone.

I can use nearly all the editor's features except for attaching images, which I'm not sure is possible on mobile. The distraction-free environment is clean and makes a lot of text fit on the screen.

Markdown formatting

Here's some rich text I'm typing with Markdown syntax in italics and bold. Some Python code:

def square(x):
    return x * x

A bullet list:

  • one
  • two
  • three

A numbered list:

  1. one
  2. two
  3. three

Quoted text:

This is quoted text. I wish I had some witty thought to share for the occasion.

And finally some displayed MathJax: $$y = f(x)$$

Conclusion

The Write.as editor is quite usable for posting text content on mobile. The only limit is how fast I can type with the on-screen keyboard.

#blogging #Android

Discuss... Email | Reply @amoroso@fosstodon.org

I wrote Twirl, an Intel 8080 Assembly program that displays the ASCII animation of a bar twirling at the home position of the terminal screen. To make things a bit more clear I recorded a screencast to show the running program and what the animation looks like.

Motivation

I developed this short program as an Assembly learning exercise related to Suite8080, a suite of Intel 8080 Assembly cross-development tools in Python I'm working on. The project, which is a lot of fun, drove me down a rabbit hole of Intel 8080 Assembly, CP/M, and retrocomputing.

I additionally wanted to explore the emuStudio execution environment and get the algorithm working. Now that it does, I can port Twirl to CP/M and add the program to Suite8080 as an Assembly demo.

The execution environment

Twirl runs on a virtual Altair 8800 computer in emuStudio, a beautiful emulator and Assembly development environment that can recreate a number of classic computers and CPUs.

I designed Twirl to run on a bare Altair 8800 connected to a Lear Siegler ADM-3A terminal. Any amount of RAM will do as the assembled code is only a few dozen bytes long. In the execution environment there's no host operating system or resident monitor, just a few basic character I/O subroutines emuStudio ships with.

Once started, Twirl runs an infinite animation loop. To terminate it I click the emuStudio Stop emulation button.

By default the Altair 8800 runs at 2 Mhz in emuStudio, which causes some terminal flicker when executing Twirl. That's why I usually set the CPU frequency to 4 MHz, closer to that of late CP/M computers.

The code

Here's the source code of Twirl:

; twirl.asm
; Twirling bar animation
;
; Runs in emuStudio emulating an Altair 8800 with an
; ADM-3A terminal


FRAMES          equ     8               ; Number of animation frames


                push    h
                lxi     h, CLS
                call    putstr          ; Clear screen
                pop     h

loop:           lxi     h, ANIM
                mvi     b, FRAMES

loop1:          push    h
                lxi     h, HOME
                call    putstr          ; Go to home
                pop     h

                mov     a, m
                push    h
                call    putchar         ; Print current frame
                pop     h

                inx     h
                dcr     b
                jnz     loop1

                jmp     loop

                hlt


CLS:            db      1ah, 0          ; ADM-3A escape sequence
HOME:           db      1eh, 0          ; ADM-3A escape sequence
ANIM:           db      '|/-\|/-\'      ; 8 frames


include 'include\putstr.inc'
include 'include\putchar.inc'

After clearing the screen, the program starts an infinite loop that repeats going through each frame of the animation, moving the cursor to the home position, and printing the current frame. The animation consists of a byte array containing the sequence of characters — frames — to display.

Some data definitions follow, i.e. the ADM-3A escape sequences to clear the screen and go to home, as well as the animation array.

The program ends with include directives for importing the following I/O subroutines:

  • putstr: prints to the terminal the 0-terminated string pointed to by the HL register pair
  • putchar: prints to the terminal the character in register A

The calls are enclosed in code that saves and restores the registers the subroutines overwrite.

Future work

What does it take to port Twirl to CP/M?

I use z80pack as my main CP/M emulator, so I design the Suite8080 demos to run on a machine with a VT100 or compatible terminal like the CP/M systems z80pack emulates.

I'll begin by converting the terminal escape codes from ADM-3A to VT100. Next, I'll replace the subroutine calls to equivalent BDOS calls. Finally, I want to support terminating the program by pressing any key. This will require code to check the console status for key presses.

#intel8080 #Assembly

Discuss... Email | Reply @amoroso@fosstodon.org

Chrome OS is my only desktop operating system and I store nearly all data in the cloud.

When on a website or online platform I see a file I want to keep, such as a PDF document or an image, I save it from Chrome to the local storage of my Chrome OS device. From there I upload the file to Google Drive and remove the temporary local copy.

But I keep forgetting Chrome OS provides a more straightforward, cloud-to-cloud way of doing it without going through the local storage.

The Files app, the Chrome OS file manager, natively mounts my Google Drive space under Google Drive > My files and makes it accessible like a local folder tree. All I need to do to save an online file is to navigate to the desired Google Drive folder via the file save system dialog, a specialized version of the Files app.

#chromeOS

Discuss... Email | Reply @amoroso@fosstodon.org

Enter your email to subscribe to updates.