Once, I wanted to draw lines on the screen. On a model III.

Man i fought and fought that code. You see, to get good old y=mx+b from a starting point and an end point, you have 2 cases. In one, m is <=1, you can loop with x. If m>1 then you have to loop on y. And I was convinced there was some clever way to do both cases with the same code! Drove me crazy for months!

Then I finally looked it up. Bresenham's Algorithm. Looks at m and then either loops on x or it loops on y. Don't be clever.

Tonight I was reminded of this...
So, there's an old 8080 cross assembler for unix that I use, asm80. There are others around, but asm80 does a better job of being compatible with CP/M's ASM.COM. Its insides were last touched in 2011, when a net.friend and I modernised the source enough for current gcc to be happy.

Then my net.friend ran out of spoons and I found a bad bug in asm80.

Show thread

If you said " DB 'hello world'" it was fine. If you said "DB 'H'" it was fine. If you said "DB 67" it was fine. If you said "DB 60+7" it was fine

but if you said "DB 'X'+80" it threw an error.

Hunting through the code was easy. The "db" handler looks at each element. If source started with a qoute, db() called the handler for ascii blocks, which reads and emits the bytes until it finds a closing quote, and then db() would freak when it found an operator instead of a comma or eol.

Show thread

I tried to fix this. several times. it defeated me. Since it would work if I said "DB ('X'+80) " I just put up with it.

until tonight!
Every time I tried to fix this code I tried to be clever with it, and it never worked. So tonight I said, forget that! All I had to do, when db() found an opening quote, don't be clever. Just look 2 more characters ahead. If i see a closing quote I can just hand the whole thing off to expr(), otherwise the ascii handler gets it.

And it works!

There is some duplicate code. So what!? A 32bit unix box, even a pi1, can afford a hundred or so bytes.

That was my night well spent. Will upload new version tomorrow, ill post the url here.

Show thread

all right, as promised!

asm80 unix cross assembler. Now handles DB pseudo ops of the style "DB 'X'+80H" correctly!

@retrocomputing #8080

Show thread
Sign in to participate in the conversation
Mastodon @ SDF

"I appreciate SDF but it's a general-purpose server and the name doesn't make it obvious that it's about art." - Eugen Rochko