For the past couple of weeks I've had my head metaphorically underwater as I drown myself in writing hardcore assembly for the first-time in two CGA routines: line and filled-triangle drawing. Both of these are based on Bresenham's algorithms which are fundamentally referred to as DDA (digital differential analyzers) and use the concept of integer error accumulators in order to approximate a line via pixels. Consider these two lines:
It's possible to override the implied segment of an instruction with a prefix. I was trying to figure out how to do this in DEBUG, specifically to copy the byte at ES:[DI] into AL. I couldn't figure out the correct syntax and the MSDN reference was not helping. I finally just looked up the machine code of such a prefix (26h) and then looked at what DEBUG disassembled it as:
Code:0100 BF0301 MOV DI,0103 ; set DI to next instruction byte 0103 26 ES: ; 26h = ES segment prefix override
The DEBUG utility included with DOS (and FreeDOS) is an awesome experimental and hobbyist programming platform, but can it be used for professional programs and full blown software? I think so.
My first computer programming was done on Apple II's during a special class in elementary school. I still don't know how I got put into it but we used LOGO to do cool graphics shit with the "turtle". I don't remember much from this period. Later, my mom got a monochrome IBM AT 8088
If you've been following along then you know I'm doing some programming in assembler using DEBUG. Very early on in any program with an interface, one is faced with displaying an integer in decimal (base 10) which means converting it to ASCII characters. It's the end of the day for me so I didn't want to get too fancy but I did want to try this on my own and here's what I've come up with ...
Code:XOR DX, DX ; zero DX (used for high word in 32 bit divide) DIV BX ; divide by decimal
In Magenta's Maze the core of the puzzle is finding the roots of a polynomial equation. When I wrote the main game, I wasn't sure how far I'd take that so I made some generalized math functions that do this allowing for arbitrary amounts of terms, roots, etc. This is cool but makes it difficult to translate to assembly. Thankfully there is a certain amount of predictability such that I can simplify the algorithm.
The only roots allowed are 1 to 9 which, as terms, show as (x - ?) where