Close

Program for driving the boot process

A project log for Bootstrapping a ROMless Z80 using RS-232

Is it possible to bootstrap a simple ROMless Z80 system using only two wires - e.g. from an RS232 interface? This project explores this.

willstevenswill.stevens 02/03/2024 at 07:110 Comments

I’ve added a link to the GitHub repo ‘TwoWireBootZ80’ which will be used for the program that will run on a PC to drive the booting process. The program is written in C because I already have some code for using the serial port written in C, and I’ll be compiling and running it on an ancient laptop  (an Asus Eee PC) that I use for electronics projects.

The core of the program is this function:

void SetMem(unsigned char *m, int n)
{
  unsigned char l=0;

  for(int i=0; i<n; i++)
  {
    m[i]=(m[i]+0xDC) & 0xFF;

    if (m[i] > l)
      l = m[i];

    SetAtHLIncHL();
  }

  for(;l>0;l--)
  {
    printf("Iteration l=%d\n",(int)l);
    for(int i=0; i<n; i++)
    {
      if (m[i]<l)
        SetAtHLIncHL();
      else
        IncAtHLIncHL();
    }
  }
}

It works by first of all sweeping through RAM and initialising every byte to 24h.

Then on successive sweeps it keeps some bytes fixed at 24h, and allows others to increment. For example, any bytes that need to be set to 25h would be allowed to increment only on the last sweep through RAM. Any byte set to 26h increments on the last two sweeps and so on. There could be upto 255 sweeps, if any bytes need to be set to 23h.

The program hasn’t been tried yet, so it may not work correctly.

Discussions