Well... after a session of bashin' at it... (I don't miss dos as much as I thought I did)... I've found at least part of the problem...
...
lviiva2:
cmp dx,1 ; x1, x2 have been swapped
jz lviiva3
...
...
lviiva3:
cmp dx,1
jz lviiva2
...
As you can see, once it falls into this, it never gets out. Program hung. "lviiva1:" and "lviiva4:" do the same thing. Simply commenting out the offending code keeps the program "alive", but not working quite right - some of the lines are being drawn in the wrong place. I haven't quite worked through what we *are* supposed to be doing there. Are you familiar with Bresenham's algorithm at all? I've read through how it works - he essentially starts with "y=mx+b", and hoists calculations out of the loop until practically everything is "pre-calculated" before the actual line-drawing starts. Very clever! It can be further optimized by dividing the line in two, and calling itself recursively... until it gets down to one pixel, and it plots it as it "ret"s (as I recall, that's how it goes). This implementation doesn't attempt that optimization (fortunately, perhaps). It depends on calling a different routine, depending on how the line is sloped... and that's where we're screwed up (I think). I'll have to refresh my memory on how it's supposed to go, before I can fix this, I think. I'll attach what I've got - it's "closer" but not there yet.
If you want to assemble this in "-f obj" mode for an .exe - the "trick" is that your data's in the code segment, not its own data segment, so your "startup" code should be just "push cs"/"pop ds"...
I may attempt another session at this... I'd like to get it working... but it's highly unimpressive, even when it works, and I don't think it's worth putting a lot of effort into it. A "hi-res" implementation... maybe... but mode 4? Ehhh...
Best,
Frank