PDP-11 Fractals in ASCII Art

by david 28. February 2011 20:15

Now that I have a C compiler for the PDP-11, I decided to do something interesting with it.  Drawing a fractal seemed to fit the bill, so I did a google search to see if anybody had managed to render the Mandelbrot Set in ASCII Art.  I found this Java code.  So I decided that I should port it to K&R C and see if it runs on the PDP-11.  This is the result:

Mandelbrot in ASCII

Very not bad!  And if you're interested, the K&R version came out like this:

#include <stdio.h>

/* CC
      mandel.c/A
   link mandel.obj,c:suport.obj,c:clib.obj
*/

main()
{
  float b,e,r,n,d;
  int h,c;
  for(e=1.1; e>-1.2; e-=.1)
  {
    for(b=-2; b<1; b+=.04)
    {
      if ((++c % 76)==0) printf("\r\n");
      else printf("%c",h);
      n=0;
      h=127;
      for(r=0; r*r+n*n<4 && --h>32; d=r)
      {
        r = r*r-n*n+b;
        n = 2*d*n+e;
      }
    }
  }
}

So far this has only been done in SIMH, but when I have made a physical 5.25" boot disk I will try it on the real machine.  I'm interested to know how fast (or slow) it is...

About the author

David

I'm a C# developer having worked with .Net since it was in beta.  Before that I mainly worked in C and C++.  I have been developing commercial software for more than 20 years.  I also mess around with microprocesors, but that's just for fun.  I live near Cambridge, England and at the moment I'm contracted to one of the departments at Cambridge University.

Tag cloud