<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>suite8080 — Paolo Amoroso&#39;s Journal</title>
    <link>https://journal.paoloamoroso.com/tag:suite8080</link>
    <description>Tech projects, hobby programming, and geeky thoughts of Paolo Amoroso</description>
    <pubDate>Tue, 17 Nov 2026 13:58:17 +0000</pubDate>
    <image>
      <url>https://i.snap.as/68i8povn.jpg</url>
      <title>suite8080 — Paolo Amoroso&#39;s Journal</title>
      <link>https://journal.paoloamoroso.com/tag:suite8080</link>
    </image>
    <item>
      <title>Troubleshooting a Suite8080 assembler bug</title>
      <link>https://journal.paoloamoroso.com/troubleshooting-a-suite8080-assembler-bug?pk_campaign=rss-feed</link>
      <description>The iLoad feature of the Z80-MBC2 homebrew Z80 computer allows uploading binary code that runs on the bare metal. I thought it would be f...</description>
      <content:encoded><![CDATA[<p>The iLoad feature of the <a href="https://journal.paoloamoroso.com/tag:z80mbc2">Z80-MBC2</a> homebrew Z80 computer allows uploading binary code that runs on the bare metal.</p>

<p>I thought it would be fun to try iLoad with some Intel 8080 code generated by the <code>asm80</code> assembler of <a href="https://journal.paoloamoroso.com/tag:Suite8080">Suite8080</a>, the suite of 8080 Assembly cross-development tools I&#39;m writing in Python. But the code crashed the Z80-MBC2, uncovering a major <code>asm80</code> bug.</p>

<p>It all started when, to practice the toolchain and process, I started with a <a href="https://journal.paoloamoroso.com/testing-hex-file-upload-to-the-z80-mbc2">Z80 Assembly demo that comes with the Z80-MBC2</a>, which prints a message to the console and blinks one of the devices&#39;s LEDs. I assembled the program with the <a href="https://k1.spdns.de/Develop/Projects/zasm/Distributions">zasm</a> Z80 and 8080 assembler, uploaded it via iLoad, and successfully ran it.</p>

<p>Next, I ported the blinking LED demo from Z80 to 8080 code and assembled it with <code>asm80</code>. But when <a href="https://journal.paoloamoroso.com/first-attempt-at-porting-a-z80-led-blink-demo-to-8080">I ran the demo on the Z80-MBC2, it crashed the device</a>.</p>

<p>The baffling crash left me stuck for threee months, as I had no tools for debugging on the bare metal and there were only a few vague clues.</p>

<p>I carefully studied the less than a hundred lines of code and they looked fine. To isolate the issue I cut the code in half, leaving the part that prints a message to the console, and transforming the blinking demo into this <code>bare.asm</code> hello world for the bare metal:</p>

<pre><code class="language-asm">OPCODE_PORT     equ     01h
EXEC_WPORT      equ     00h
TX_OPCODE       equ     01h
EOS             equ     00h
CR              equ     0dh
LF              equ     0ah


                org     0h

                jmp     start

                ds      16
stack:


start:          lxi     sp, start
                lxi     h, message
                call    puts

                hlt


message:        db      CR, LF, &#39;Greetings from the bare metal&#39;, CR, LF, EOS


puts:           push    psw
                push    h
puts_loop:      mov     a, m
                cpi     EOS
                jz      puts_end
                call    putc
                inx     h
                jmp     puts_loop
puts_end:       pop     h
                pop     psw
                ret


putc:           push    psw
                mvi     a, TX_OPCODE
                out     OPCODE_PORT
                pop     psw
                out     EXEC_WPORT
                ret

                end
</code></pre>

<p>The constants at the beginning define the addresses of the output ports, the opcode for sending a character over the serial line, and a couple of control characters. Next, the program sets up the stack and iterates over the output string to print every character.</p>

<p>The simplified demo program still crashed the Z80-MBC2, forcing me back to the drawing board.</p>

<p>Then I had an epiphany. What if the binary code <code>asm80</code> generates is different from <code>zasm</code>&#39;s?</p>

<p>I fired up the <code>dis80</code> disassembler of Suite8080 and compared the output of the assemblers. Sure enough, the difference jumped at me: the destination addresses of all the branches after the label <code>message</code> are off by 5 bytes.</p>

<p>The instructions branch to addresses 5 bytes lower, so the call to <code>puts</code> executes random string data that chrashes the device. The last correct address <code>asm80</code> outputs is that of the label <code>message</code>. The address of the next one, <code>puts</code>, is wrong and leads to the crash.</p>

<p>Indeed, the same demo code assembled with <code>zasm</code> ran fine on the Z80-MBC2 and printed the expected message. This confirmed my hunch.</p>

<p>What now?</p>

<p>The next step is to find the bug in the Python source of <code>asm80</code>, which I&#39;m developing with <a href="https://replit.com">Replit</a>. Although Replit provides a debugger, I won&#39;t use it. The tool is not well documented and I&#39;m not sure how it works. In addition the Replit debugger is best suited to code started from the run button. This is inconvenient for command line programs like the Python scripts of Suite8080.</p>

<p>Therefore, I&#39;ll take the opportunity to use Python&#39;s native debugger <code>pdb</code>, which I always wanted to try in a real project. I played with <code>pdb</code> a bit and it looks easy to use, with all the commands and options handy.</p>

<p>Let&#39;s see if <code>pdb</code> can help me pinpoint the bug in the Python code.</p>

<p><a href="https://journal.paoloamoroso.com/tag:Suite8080" class="hashtag"><span>#</span><span class="p-category">Suite8080</span></a> <a href="https://journal.paoloamoroso.com/tag:z80mbc2" class="hashtag"><span>#</span><span class="p-category">z80mbc2</span></a> <a href="https://journal.paoloamoroso.com/tag:Assembly" class="hashtag"><span>#</span><span class="p-category">Assembly</span></a> <a href="https://journal.paoloamoroso.com/tag:Python" class="hashtag"><span>#</span><span class="p-category">Python</span></a></p>

<p><a href="https://remark.as/p/journal.paoloamoroso.com/troubleshooting-a-suite8080-assembler-bug">Discuss...</a>
<a href="mailto:info@paoloamoroso.com?subject=Reply%20to%20Paolo%20Amoroso%27s%20Journal">Email</a> | Reply <a href="/@/amoroso@oldbytes.space" class="u-url mention">@<span>amoroso@oldbytes.space</span></a></p>


]]></content:encoded>
      <guid>https://journal.paoloamoroso.com/troubleshooting-a-suite8080-assembler-bug</guid>
      <pubDate>Wed, 28 Dec 2022 12:42:50 +0000</pubDate>
    </item>
    <item>
      <title>First attempt at porting a Z80 led blink demo to 8080</title>
      <link>https://journal.paoloamoroso.com/first-attempt-at-porting-a-z80-led-blink-demo-to-8080?pk_campaign=rss-feed</link>
      <description>I ported to Intel 8080 Assembly the Z80-MBC2 Z80 code of the led blink demo, assembled it with the Suite8080 assembler, and uploaded the ...</description>
      <content:encoded><![CDATA[<p>I ported to Intel 8080 Assembly the <a href="https://journal.paoloamoroso.com/tag:z80mbc2">Z80-MBC2</a> Z80 code of the <a href="https://journal.paoloamoroso.com/testing-hex-file-upload-to-the-z80-mbc2">led blink demo</a>, assembled it with the <a href="https://journal.paoloamoroso.com/tag:Suite8080">Suite8080</a> assembler, and <a href="https://journal.paoloamoroso.com/testing-hex-file-upload-to-the-z80-mbc2">uploaded</a> the HEX binary to the Z80-MBC2. Instead of printing a message to the console and blinking the User led, the program made the led turn on and the board reset, booting up the default operating system.</p>

<p>I have no tools to debug software that runs on the bare metal. So the next step is to investigate these clues, starting from a comparison of the Z80 and 8080 sources.</p>

<p><a href="https://journal.paoloamoroso.com/tag:Assembly" class="hashtag"><span>#</span><span class="p-category">Assembly</span></a> <a href="https://journal.paoloamoroso.com/tag:z80mbc2" class="hashtag"><span>#</span><span class="p-category">z80mbc2</span></a> <a href="https://journal.paoloamoroso.com/tag:Suite8080" class="hashtag"><span>#</span><span class="p-category">Suite8080</span></a></p>

<p><a href="https://remark.as/p/journal.paoloamoroso.com/first-attempt-at-porting-a-z80-led-blink-demo-to-8080">Discuss...</a>
<a href="mailto:info@paoloamoroso.com?subject=Reply%20to%20Paolo%20Amoroso%27s%20Journal">Email</a> | Reply <a href="/@/amoroso@oldbytes.space" class="u-url mention">@<span>amoroso@oldbytes.space</span></a></p>


]]></content:encoded>
      <guid>https://journal.paoloamoroso.com/first-attempt-at-porting-a-z80-led-blink-demo-to-8080</guid>
      <pubDate>Mon, 12 Sep 2022 15:49:06 +0000</pubDate>
    </item>
    <item>
      <title>Debugging CP/M 8080 code on the Z80-MBC2</title>
      <link>https://journal.paoloamoroso.com/debugging-cp-m-8080-code-on-the-z80-mbc2?pk_campaign=rss-feed</link>
      <description>I develop programs for the Z80-MBC2 in Intel 8080 Assembly with the Suite8080 8080 assembler. Aside from the binary compatibility, the Z8...</description>
      <content:encoded><![CDATA[<p>I develop programs for the <a href="https://journal.paoloamoroso.com/tag:z80mbc2">Z80-MBC2</a> in Intel 8080 Assembly with the <a href="https://journal.paoloamoroso.com/tag:Suite8080">Suite8080</a> 8080 assembler. Aside from the binary compatibility, the Z80-MBC2 is a Z80 system, so I wondered what Assembly mnemonics and register set the CP/M development tools work with.</p>

<p>It turns out <a href="https://blog.paoloamoroso.com/2021/12/suite8080-040.html">my favorite CP/M debugger</a>, the SID symbolic debugger, comes in two versions specialized on the CPU, SID and ZSID.</p>

<p>SID accepts as input and outputs 8080 mnemonics and registers, ZSID Z80 mnemonics and registers. For example, in this CP/M 3.0 SID session on the Z80-MBC2 I loaded my <a href="https://journal.paoloamoroso.com/porting-a-twirling-bar-demo-to-cp-m">Twirl</a> 8080 program and disassembled it with SID&#39;s <code>l</code> (list) command:</p>

<pre><code>A&gt;sid f:twirl.com
CP/M 3 SID - Version 3.0
NEXT MSZE  PC  END
0180 0180 0100 D4FF
#l
  0100  MVI  C,09
  0102  LXI  D,0139
  0105  CALL 0005
  0108  LXI  H,0142
  010B  MVI  B,08
  010D  PUSH H
  010E  PUSH B
  010F  MVI  C,09
  0111  LXI  D,013E
  0114  CALL 0005
  0117  POP  B7
</code></pre>

<p>The output contains 8080 mnemonics. An analogous ZSID session running the same disassembly command outputs Z80 mnemonics:</p>

<pre><code>A&gt;zsid f:twirl.com
SID VERS 1.4
NEXT  PC  END
0180 0100 CDFF
#l
  0100  LD   C,09
  0102  LD   DE,0139
  0105  CALL 0005
  0108  LD   HL,0142
  010B  LD   B,08
  010D  PUSH HL
  010E  PUSH BC
  010F  LD   C,09
  0111  LD   DE,013E
  0114  CALL 0005
  0117  POP  BC
</code></pre>

<p>SID thus lets me work in a 8080 environment on a Z80 system.</p>

<p><a href="https://journal.paoloamoroso.com/tag:z80mbc2" class="hashtag"><span>#</span><span class="p-category">z80mbc2</span></a> <a href="https://journal.paoloamoroso.com/tag:Suite8080" class="hashtag"><span>#</span><span class="p-category">Suite8080</span></a> <a href="https://journal.paoloamoroso.com/tag:CPM" class="hashtag"><span>#</span><span class="p-category">CPM</span></a> <a href="https://journal.paoloamoroso.com/tag:Assembly" class="hashtag"><span>#</span><span class="p-category">Assembly</span></a></p>

<p><a href="https://remark.as/p/journal.paoloamoroso.com/debugging-cp-m-8080-code-on-the-z80-mbc2">Discuss...</a>
<a href="mailto:info@paoloamoroso.com?subject=Reply%20to%20Paolo%20Amoroso%27s%20Journal">Email</a> | Reply <a href="/@/amoroso@oldbytes.space" class="u-url mention">@<span>amoroso@oldbytes.space</span></a></p>


]]></content:encoded>
      <guid>https://journal.paoloamoroso.com/debugging-cp-m-8080-code-on-the-z80-mbc2</guid>
      <pubDate>Wed, 24 Aug 2022 15:56:05 +0000</pubDate>
    </item>
    <item>
      <title>I&#39;ve started writing a new Suite8080 demo in Intel 8080 Assembly, a CP/M...</title>
      <link>https://journal.paoloamoroso.com/ive-started-writing-a-new-suite8080-demo-in-intel-8080-assembly-a-cp-m?pk_campaign=rss-feed</link>
      <description>I&#39;ve started writing a new Suite8080 demo in Intel 8080 Assembly, a CP/M program to move an ASCII character across the screen with vi&#39;s c...</description>
      <content:encoded><![CDATA[<p>I&#39;ve started writing a new <a href="https://journal.paoloamoroso.com/tag:Suite8080">Suite8080</a> demo in Intel 8080 Assembly, a CP/M program to move an ASCII character across the screen with <code>vi</code>&#39;s cursor keys <code>h</code>, <code>j</code>, <code>k</code>, and <code>l</code>. It&#39;s my first interactive CP/M program and does raw non-blocking I/O to read key presses.</p>

<p><a href="https://journal.paoloamoroso.com/tag:Assembly" class="hashtag"><span>#</span><span class="p-category">Assembly</span></a> <a href="https://journal.paoloamoroso.com/tag:Suite8080" class="hashtag"><span>#</span><span class="p-category">Suite8080</span></a></p>

<p><a href="https://remark.as/p/journal.paoloamoroso.com/ive-started-writing-a-new-suite8080-demo-in-intel-8080-assembly-a-cp-m">Discuss...</a>
<a href="mailto:info@paoloamoroso.com?subject=Reply%20to%20Paolo%20Amoroso%27s%20Journal">Email</a> | Reply <a href="/@/amoroso@oldbytes.space" class="u-url mention">@<span>amoroso@oldbytes.space</span></a></p>


]]></content:encoded>
      <guid>https://journal.paoloamoroso.com/ive-started-writing-a-new-suite8080-demo-in-intel-8080-assembly-a-cp-m</guid>
      <pubDate>Sat, 20 Aug 2022 16:03:18 +0000</pubDate>
    </item>
    <item>
      <title>Next Suite8080 features: trim uninitialized data, macro assembler</title>
      <link>https://journal.paoloamoroso.com/next-suite8080-features-trim-uninitialized-data-macro-assembler?pk_campaign=rss-feed</link>
      <description>I decided what to work on next on Suite8080, the suite of Intel 8080 Assembly cross-development tools I&#39;m writing in Python. I&#39;ll add two...</description>
      <content:encoded><![CDATA[<p>I decided what to work on next on <a href="https://journal.paoloamoroso.com/tag:Suite8080">Suite8080</a>, the suite of Intel 8080 Assembly cross-development tools I&#39;m writing in Python. I&#39;ll add two features, the ability for the assembler to trim trailing uninitialized data and a macro assembler script.</p>

<h2 id="trimming-uninitialized-data">Trimming uninitialized data</h2>

<p>Consider this 8080 Assembly code, which declares a 1024 bytes uninitialized data area at the end of the program:</p>

<pre><code class="language-asm"># . . .

data:        ds    1024
             end
</code></pre>

<p>For this <code>ds</code> directive, the Suite8080 assembler <code>asm80</code> emits a sequence of 1024 null bytes at the end of the binary program. The executable file is thus longer and may be slower to load on the host system, typically CP/M.</p>

<p>The Digital Research CP/M assemblers, <code>ASM.COM</code> and <code>MAC.COM</code>, strip such trailing uninitialized data from binaries. After <a href="https://www.reddit.com/r/asm/comments/v9y32g/ds_section_at_end_of_program_strip_or_keep_the/">asking for feedback to r/asm</a>, I decided to do the same with <code>asm80</code>. I should be able to implement this optimization by adding just one line of Python, so the feature is a low-hanging fruit.</p>

<h2 id="macro-assembler">Macro assembler</h2>

<p><code>asm80</code> can accept source files from standard input, which makes it possible to combine the assembler with <a href="https://www.youtube.com/watch?v=euh0gaT3tA0">an external macro preprocessor to get a macro assembler</a>. Thanks to its ubiquity, M4 is the clear choice for a preprocessor.</p>

<p>Assuming <code>prog.asm</code> is an 8080 Assembly source file containing M4 macros, this shell pipe can assemble it with <code>asm80</code>:</p>

<pre><code class="language-bash">$ cat prog.asm | m4 | asm80 - -o prog.com
</code></pre>

<p>The <code>-</code> option accepts input from standard input and <code>-o</code> sets the file name of the output binary program.</p>

<p>The other Suite8080 feature I&#39;m going to implement is a <code>mac80</code> helper script in Python to wrap such a shell pipe and make assembling macro files more convenient. In other words, syntactic sugar wrapping <code>asm80</code> and M4.</p>

<p>The script will use the Python <code>subprocess</code> module to set up the pipe, feed the proprocessed source to the assembler, and not much else.</p>

<p><a href="https://journal.paoloamoroso.com/tag:Suite8080" class="hashtag"><span>#</span><span class="p-category">Suite8080</span></a> <a href="https://journal.paoloamoroso.com/tag:Python" class="hashtag"><span>#</span><span class="p-category">Python</span></a></p>

<p><a href="https://remark.as/p/journal.paoloamoroso.com/next-suite8080-features-trim-uninitialized-data-macro-assembler">Discuss...</a>
<a href="mailto:info@paoloamoroso.com?subject=Reply%20to%20Paolo%20Amoroso%27s%20Journal">Email</a> | Reply <a href="/@/amoroso@oldbytes.space" class="u-url mention">@<span>amoroso@oldbytes.space</span></a></p>


]]></content:encoded>
      <guid>https://journal.paoloamoroso.com/next-suite8080-features-trim-uninitialized-data-macro-assembler</guid>
      <pubDate>Sat, 13 Aug 2022 12:54:07 +0000</pubDate>
    </item>
    <item>
      <title>Updating the Suite8080 documentation build process</title>
      <link>https://journal.paoloamoroso.com/updating-the-suite8080-documentation-build-process?pk_campaign=rss-feed</link>
      <description>It all started when I added a new Intel 8080 Assembly demo to Suite8080. Pushing the commit to the GitHub repo triggered a rebuild of the...</description>
      <content:encoded><![CDATA[<p>It all started when I added a <a href="https://journal.paoloamoroso.com/porting-a-twirling-bar-demo-to-cp-m">new Intel 8080 Assembly demo</a> to <a href="https://journal.paoloamoroso.com/tag:Suite8080">Suite8080</a>. Pushing the commit to the GitHub repo triggered a rebuild of the project <a href="https://suite8080.readthedocs.io">documentation hosted on Read The Docs</a>, which <a href="https://readthedocs.org/projects/suite8080/builds/17347725/">failed</a>.</p>

<p>I <a href="https://blog.paoloamoroso.com/2022/01/publishing-python-documentation-to-read.html">maintain the Suite8080 documentation</a> with Jupyter Book and publish it to Read The Docs with Sphinx as the backend.</p>

<p>Over the previous months, while my <a href="https://journal.paoloamoroso.com/preparing-to-resume-work-on-suite8080">work on Suite8080 was on hold</a>, some backward incompatible Jupyter Book update broke the Suite8080 documentation configuration. I had no idea what to do, so I <a href="https://github.com/readthedocs/readthedocs.org/issues/9405">opened a Read The Docs issue</a>. After some troubleshooting with the help of Manuel Kaufmann, Benjamin Balder Bach contributed a <a href="https://github.com/pamoroso/suite8080/pull/1">Suite8080 pull request</a> that fixed the issue.</p>

<p>Benjamin&#39;s patch has an additional advantage. I no longer have to manually edit <code>conf.py</code> to let <code>sphinx.ext.autodoc</code> discover the project&#39;s Python packages.</p>

<p><a href="https://journal.paoloamoroso.com/tag:Suite8080" class="hashtag"><span>#</span><span class="p-category">Suite8080</span></a> <a href="https://journal.paoloamoroso.com/tag:Python" class="hashtag"><span>#</span><span class="p-category">Python</span></a></p>

<p><a href="https://remark.as/p/journal.paoloamoroso.com/updating-the-suite8080-documentation-build-process">Discuss...</a>
<a href="mailto:info@paoloamoroso.com?subject=Reply%20to%20Paolo%20Amoroso%27s%20Journal">Email</a> | Reply <a href="/@/amoroso@oldbytes.space" class="u-url mention">@<span>amoroso@oldbytes.space</span></a></p>


]]></content:encoded>
      <guid>https://journal.paoloamoroso.com/updating-the-suite8080-documentation-build-process</guid>
      <pubDate>Sat, 30 Jul 2022 14:31:34 +0000</pubDate>
    </item>
    <item>
      <title>Porting a twirling bar demo to CP/M</title>
      <link>https://journal.paoloamoroso.com/porting-a-twirling-bar-demo-to-cp-m?pk_campaign=rss-feed</link>
      <description>I ported to CP/M Twirl, a twirling bar animation demo in Intel 8080 Assembly. I originally developed it for emuStudio, an emulator and de...</description>
      <content:encoded><![CDATA[<p>I ported to CP/M Twirl, a <a href="https://journal.paoloamoroso.com/contributing-an-8080-demo-to-emustudio">twirling bar animation demo</a> in Intel 8080 Assembly. I originally developed it for <a href="https://www.emustudio.net">emuStudio</a>, an emulator and development environment that recreates a number of classic computers and CPUs. The port runs on any CP/M system with an ANSI terminal or display.</p>

<p>I recorded a <a href="https://www.youtube.com/watch?v=Oyh4_6kPShQ">screencast that shows Twirl running under CP/M 3.0</a> on the <a href="https://journal.paoloamoroso.com/tag:z80mbc2">Z80-MBC2 computer</a>, controlled from a Minicom terminal emulator session under Crostini Linux on my Chromebox.</p>

<h2 id="how-it-works">How it works</h2>

<p>The demo displays an ASCII animation of a bar twirling clockwise at the home position of the console, i.e. the top left corner. After clearing the screen, Twirl repeatedly moves the cursor to the console home, prints the current animation frame, and checks for key presses to decide whether to terminate.</p>

<p>Although visually simple, the program demonstrates some key Assembly programming techniques such as looping, calling BDOS functions, and doing output with ANSI escape codes.</p>

<h2 id="porting">Porting</h2>

<p>The <a href="https://journal.paoloamoroso.com/twirl-an-intel-8080-assembly-program">original Twirl</a> runs on a virtual Altair 8800 computer with a Lear Siegler ADM-3A terminal emulated by emuStudio.</p>

<p>However, I designed the program intending to port it to CP/M. The necessary work consisted in replacing the Altair-specific I/O rutines with equivalent BDOS calls for printing a single character (function <code>02h</code>) and a string (<code>09h</code>) of ANSI escape codes, and checking the console status for key presses (<code>0bh</code>).</p>

<p>The program logic works as is, but I had to modify the CP/M version for defining the appropriate constants and ANSI escape strings, as well as adapting to the execution environment of the operating system and returning control to it.</p>

<h2 id="building-and-running">Building and running</h2>

<p>For me, the whole point of writing programs like Twirl and getting Z80 hardware is to use <a href="https://github.com/pamoroso/suite8080">Suite8080</a>, the suite of Intel 8080 Assembly cross-development tools I&#39;m writing in Python. The CP/M port is a new <a href="https://github.com/pamoroso/suite8080/blob/master/asm/twirl.asm">Suite8080 Assembly demo</a> I built from source on Linux with <code>asm80</code>, the Suite8080 assembler:</p>

<pre><code class="language-bash">$ asm80 twirl.asm
</code></pre>

<p>I tested the resulting 74 bytes <code>twirl.com</code> executable under CP/M 2.2 with the CP/M software emulators <a href="https://github.com/jhallen/cpm">ANSI CP/M emulator</a> and <a href="https://www.autometer.de/unix4fun/z80pack">z80pack</a>.</p>

<p>Running the demo at the CP/M prompt is straightoward:</p>

<pre><code class="language-msdos">B&gt;twirl
</code></pre>

<p>Pressing any key quits Twirl and returns control to the operating system.</p>

<p>To exeute Twirl on actual hardware I converted <code>twirl.com</code> to Intel HEX format with z80pack&#39;s <code>bin2hex</code> tool, then <a href="https://journal.paoloamoroso.com/a-workaround-for-sending-files-to-the-z80-mbc2">transferred the <code>twirl.hex</code> file to the Z80-MBC2</a> under CP/M 3.0.</p>

<p>It was really rewarding to see Twirl come to life on a real Z80 computer and get a sense of its performance.</p>

<h2 id="the-code">The code</h2>

<p>Here is the full code of the CP/M port of Twirl:</p>

<pre><code class="language-asm">; Twirling bar animation.
;
; Runs on CP/M with an ANSI terminal. Press any key to quit the program.


TPA        equ      100h
BDOS       equ      0005h
WRITESTR   equ      09h                ; Write string
WRITECHR   equ      02h                ; Write character
CONSTAT    equ      0bh                ; Console status

FRAMES     equ      8                  ; Number of animation frames


           org      TPA
            
           mvi      c, WRITESTR
           lxi      d, cls             ; Clear screen
           call     BDOS

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

loop1:     push     h
           push     b
           mvi      c, WRITESTR
           lxi      d, home            ; Go to screen home
           call     BDOS
           pop      b
           pop      h

           push     h
           push     b
           mvi      c, WRITECHR
           mov      e, m               ; Print current frame
           call     BDOS
           pop      b
           pop      h

           push     h
           push     b
           mvi      c, CONSTAT         ; Get console status
           call     BDOS
           pop      b
           pop      h
           ora      a                  ; Key pressed?
           jnz      exit               ; Yes

           inx      h                  ; Point to next frame
           dcr      b                  ; One fewer frame
           jnz      loop1

           jmp      loop

exit:      ret


cls:       db       1bh, &#39;[2J$&#39;        ; ANSI clear screen: ESC [ 2 J
home:      db       1bh, &#39;[H$&#39;         ; ANSI go to screen home: ESC [ H
anim:      db       &#39;|/-\|/-\&#39;         ; 8 frames

           end
</code></pre>

<p>The program represents the animation as the string <code>|/-\|/-\</code>, a sequence of ASCII characters that show the bar at various steps of the rotation.</p>

<p>After clearing the screen, Twirl begins the main loop <code>loop:</code> by initializing the frame pointer and count. An inner loop <code>loop1:</code> prints each animation frame, i.e. the characters of the animation sequence.</p>

<p>The inner loop moves the cursor to the home position and prints the current frame. Then it updates the frame pointer and count, and checks whether a key was pressed. In case of a key press the inner loop exits the program, otherwise it jumps back to the beginning of the main loop.</p>

<p><a href="https://journal.paoloamoroso.com/tag:Assembly" class="hashtag"><span>#</span><span class="p-category">Assembly</span></a> <a href="https://journal.paoloamoroso.com/tag:retrocomputing" class="hashtag"><span>#</span><span class="p-category">retrocomputing</span></a> <a href="https://journal.paoloamoroso.com/tag:Suite8080" class="hashtag"><span>#</span><span class="p-category">Suite8080</span></a> <a href="https://journal.paoloamoroso.com/tag:z80mbc2" class="hashtag"><span>#</span><span class="p-category">z80mbc2</span></a> <a href="https://journal.paoloamoroso.com/tag:CPM" class="hashtag"><span>#</span><span class="p-category">CPM</span></a></p>

<p><a href="https://remark.as/p/journal.paoloamoroso.com/porting-a-twirling-bar-demo-to-cp-m">Discuss...</a>
<a href="mailto:info@paoloamoroso.com?subject=Reply%20to%20Paolo%20Amoroso%27s%20Journal">Email</a> | Reply <a href="/@/amoroso@oldbytes.space" class="u-url mention">@<span>amoroso@oldbytes.space</span></a></p>


]]></content:encoded>
      <guid>https://journal.paoloamoroso.com/porting-a-twirling-bar-demo-to-cp-m</guid>
      <pubDate>Mon, 04 Jul 2022 16:06:37 +0000</pubDate>
    </item>
    <item>
      <title>A hello world Assembly demo running on the Z80-MBC2</title>
      <link>https://journal.paoloamoroso.com/a-hello-world-assembly-demo-running-on-the-z80-mbc2?pk_campaign=rss-feed</link>
      <description>In the Crostini Linux Minicom terminal emulation session of this screenshot, a hello world Intel 8080 Assembly program run under CP/M on ...</description>
      <content:encoded><![CDATA[<p>In the Crostini Linux Minicom terminal emulation session of this screenshot, a <a href="https://github.com/pamoroso/suite8080/blob/master/asm/greet.asm">hello world Intel 8080 Assembly program</a> run under CP/M on the <a href="https://journal.paoloamoroso.com/tag:z80mbc2">Z80-MBC2</a> Z80 homebrew computer, printing the string <code>Greetings from Suite8080</code> to the console.</p>

<p><a href="https://i.snap.as/i61uviwM.png"><img src="https://i.snap.as/i61uviwM.png" alt="Screenshot of a Crostini Linux Minicom session showing a hello world Assembly demo running under CP/M on a Z80-MBC2 Z80 computer."/></a></p>

<p>It may not seem like much, but it&#39;s a personal achievement I&#39;m proud of.</p>

<p>The demo program comes with <a href="https://github.com/pamoroso/suite8080">Suite8080</a>, a suite of Intel 8080 Assembly cross-development tools I&#39;m writing in Python. I created the demo, assembled it with my own assembler, and run it on actual hardware. Just a few months ago I didn&#39;t think I could do this.</p>

<p>Running the demo also helped me put together and test a cross-development toolchain based on Suite8080. For example, I learnt how to transfer files via XMODEM from Crostini to the Z80 board.</p>

<p>I can&#39;t wait to use the toolchain to develop more code for the Z80-MBC2.</p>

<p><a href="https://journal.paoloamoroso.com/tag:Suite8080" class="hashtag"><span>#</span><span class="p-category">Suite8080</span></a> <a href="https://journal.paoloamoroso.com/tag:z80mbc2" class="hashtag"><span>#</span><span class="p-category">z80mbc2</span></a> <a href="https://journal.paoloamoroso.com/tag:sbc" class="hashtag"><span>#</span><span class="p-category">sbc</span></a> <a href="https://journal.paoloamoroso.com/tag:CPM" class="hashtag"><span>#</span><span class="p-category">CPM</span></a></p>

<p><a href="https://remark.as/p/journal.paoloamoroso.com/a-hello-world-assembly-demo-running-on-the-z80-mbc2">Discuss...</a>
<a href="mailto:info@paoloamoroso.com?subject=Reply%20to%20Paolo%20Amoroso%27s%20Journal">Email</a> | Reply <a href="/@/amoroso@oldbytes.space" class="u-url mention">@<span>amoroso@oldbytes.space</span></a></p>


]]></content:encoded>
      <guid>https://journal.paoloamoroso.com/a-hello-world-assembly-demo-running-on-the-z80-mbc2</guid>
      <pubDate>Sun, 19 Jun 2022 16:03:14 +0000</pubDate>
    </item>
    <item>
      <title>Preparing to resume work on Suite8080</title>
      <link>https://journal.paoloamoroso.com/preparing-to-resume-work-on-suite8080?pk_campaign=rss-feed</link>
      <description>What I anticipated and planned for is happening. After the great momentum of the initial work on Suite8080, I set it aside for a couple o...</description>
      <content:encoded><![CDATA[<p>What I anticipated and planned for is happening.</p>

<p>After the great momentum of the initial work on <a href="https://github.com/pamoroso/suite8080">Suite8080</a>, I set it aside for a couple of months. Now I&#39;m about to resume work on the project and wonder how hard it&#39;ll be to dive back into the Python code and continue development.</p>

<p>I tried to prepare for this by documenting the system and commenting the code.  I also took many notes on to-do items, features I&#39;d like to add, and ways to implement them. At a few thousand lines, the code base is small and I hope it won&#39;t be too difficult to understand and change.</p>

<p>Still, I&#39;m a Python beginner and my code is tightly coupled, fragile, not modular, and hard to extend.</p>

<p>Suite8080 is a suite of Intel 8080 Assembly cross-development tools I&#39;m writing in Python.</p>

<p><a href="https://journal.paoloamoroso.com/tag:Python" class="hashtag"><span>#</span><span class="p-category">Python</span></a> <a href="https://journal.paoloamoroso.com/tag:Suite8080" class="hashtag"><span>#</span><span class="p-category">Suite8080</span></a></p>

<p><a href="https://remark.as/p/journal.paoloamoroso.com/preparing-to-resume-work-on-suite8080">Discuss...</a>
<a href="mailto:info@paoloamoroso.com?subject=Reply%20to%20Paolo%20Amoroso%27s%20Journal">Email</a> | Reply <a href="/@/amoroso@oldbytes.space" class="u-url mention">@<span>amoroso@oldbytes.space</span></a></p>


]]></content:encoded>
      <guid>https://journal.paoloamoroso.com/preparing-to-resume-work-on-suite8080</guid>
      <pubDate>Fri, 13 May 2022 16:52:12 +0000</pubDate>
    </item>
    <item>
      <title>Suite8080 0.5.0 and the next steps</title>
      <link>https://journal.paoloamoroso.com/suite8080-0-5-0-and-the-next-steps?pk_campaign=rss-feed</link>
      <description>I released version 0.5.0 of Suite8080, a suite of Intel 8080 Assembly cross-development tools I&#39;m writing in Python. Although still in an...</description>
      <content:encoded><![CDATA[<p>I released <a href="https://blog.paoloamoroso.com/2022/03/suite8080-050.html">version 0.5.0</a> of <a href="https://blog.paoloamoroso.com/2021/11/an-intel-8080-assembly-suite-in-python.html">Suite8080</a>, a suite of Intel 8080 Assembly cross-development tools I&#39;m writing in Python. Although still in an early stage, this version makes Suite8080 gain enough functionality to be useful in a variety of Assembly applications.</p>

<p>In my next steps I&#39;m going to focus on two areas of improvement.</p>

<p>First, I&#39;ll write more 8080 programs to process with the Suite8080 assembler and run on emulated CP/M systems or actual hardware. After all, this is the fun part I began the project for.</p>

<p>The Suite8080 Python sources are still a tangled mess of tightly-coupled, unencapsulated, beginner code with global state that makes it difficult to add new features or change existing ones. Therefore, the other area of improvement I&#39;ll work on is a major redesign. This should make the code easier to work with and extend.</p>

<p><a href="https://journal.paoloamoroso.com/tag:Python" class="hashtag"><span>#</span><span class="p-category">Python</span></a> <a href="https://journal.paoloamoroso.com/tag:Suite8080" class="hashtag"><span>#</span><span class="p-category">Suite8080</span></a></p>

<p><a href="https://remark.as/p/journal.paoloamoroso.com/suite8080-0-5-0-and-the-next-steps">Discuss...</a>
<a href="mailto:info@paoloamoroso.com?subject=Reply%20to%20Paolo%20Amoroso%27s%20Journal">Email</a> | Reply <a href="/@/amoroso@oldbytes.space" class="u-url mention">@<span>amoroso@oldbytes.space</span></a></p>


]]></content:encoded>
      <guid>https://journal.paoloamoroso.com/suite8080-0-5-0-and-the-next-steps</guid>
      <pubDate>Sat, 19 Mar 2022 14:32:55 +0000</pubDate>
    </item>
  </channel>
</rss>