Before anybody tells me that this technology is outdated, I am aware however the scope of the project is very specific.
My requirement is to print a filled rectangle to the output by writing directly to the video memory (0x13 in real mode). I have achieved this by plotting each line along the x axis and storing the colour byte (in this case 11) to VGA memory 0xa0000 + offset. The requirements for this project however ask for a more efficient method than a loop plotting each pixel as I'm directly addressing video memory.
I can't seem to work out if there's a way to copy a single byte (value: 11) across multiple memory locations. As an experiment, I tried to copy the byte across a register by multiplying it by 0x01010... and then moving the entire two bytes to memory. That experiment was successful, it produced a horizontal line the length of two pixels starting at memory location defined by 0xa0000 + offset.
The issue I have, is this is only two bits. The resolution for 0x13 mode is 320x200, making the use of registers in such a way inefficient. I had considered the use of .string etc however that is also against the requirements of the scope. Plotting an array and allocating a size that totals 64kb on the off chance that some of those pixels may be used also sounds massively inefficient, if even possible in real mode. So that ruled that out for me.
Another factor of this not working is also the fact that sometimes lines may need to be drawn downwards rather than horizontal and won't be as simple as storing a block of bytes starting at the memory address.
Having said that however, if I can figure out a way of copying a dynamic number of the same byte to a block of memory starting at a given location then it's huge progress I can work off, so that's my current goal.
Is there any way to do this without previously allocating crazy amounts of space? Say I want to draw a line that's 18 pixels long, I want to copy a byte of value 11 into 18 bytes of a segment starting at the given offset.
Thanks in advance, I hope I've been descriptive enough.
Plotting each pixel would indeed be inefficient. The code that I show below:
I chose to pass the arguments in registers, but if you prefer you can change it so it uses the stack. This is pure 8086 code. If you target the real mode of the later cpus, then outputting at least 4 pixels at once is possible.