by waynecochran · 9y ago · 0 comments
Later I did some 8086 assembly programming. I learned why a generation of programmers hate assembly... only a few special purpose registers, segmented memory, long list of nonorthogonal instructions, ... yuck
I blame the general aversion for assembly programming to the choice of using the 8086 for PC's.
The auto-increment/decrement addressing modes were aware of the bit size. Thus you could have polymorphic subroutines where the same code could be used to sum an array of bytes, words, 13 bit quantities or whatever size word you wanted (up to 32 bits).
Since the processor had built-in circuitry to help drive graphics displays it took a high input frequency of something like 40 or 50 MHz and actually divided that down to run the processor at around 10 MHz or so. The opposite of what we're used to now and made the darn things look scary (well, scarier) from an emulation programmer's perspective.
The memory interface was designed to work with shift-register VRAM. The idea there being that the VRAM chips had a built-in shift register 512 pixels wide. The display circuitry would make use of it by having each line from the frame buffer dumped into the shift register as the raster was moving down the screen. And then the shift register would clock out the pixels as the raster moved across each line.
During VBLANK (when the video circuitry is waiting for the raster to return to the top of the screen) you could use special instructions to load and store the shift register which would be as fast as any load/store operation. The entire frame buffer could be filled very quickly with any repetitive pattern or erased entirely by copying some fixed line to all the others.
Lotta cool stuff in that beast.
There was also a built in Bressenhsm line drawing instruction.
Then there was the TMS34082 floating point coprocessor. I essentially wrote a primitive OpenGL'ish pipeline API. That was fun.
Wow... I really wish a general purpose processor like this made it into the PC. The best stuff doesn't always win in the marketplace.
And yes, Intel's instruction sets are so butt-ugly they make everybody else's look beautiful by comparison. I really wish almost any other chip had won the war for that reason. I'm encouraged by the rising profile of ARM.
I had lots of fun coding for with, initially with as86 and then TASM.
The only thing I hated with the x86 was trying to use AT&T syntax a few decades later.
I also coded for Z80, 68000 and MIPS.
Then you had real mode vs protected mode which used the same segmented registers in a completely different way -- a clever way to be backwards compatible -- long story. In real mode you have a variety of different memory models: tiny, small, large, ... -- near and far ptrs? -- ugh. 20-bit physical addresses from segment << 4 | offset. Uggggllllyyyyy....
Forget about the x87 floating point processor -- arguments go on a 8-level deep stack -- really? I got to push and pop to do floating point?
Now you have AMD-64. But all that old stuff is still there taking up transistors!
It was nice though, I wrote a backend for GNU binutils for it and wrote an X11 driver for the chip.
I loved 8086 assembly after coming from Z80. And one of the reasons it was so fast was because of minimal registers.
And 8086 was released 10 years earlier.
Well, nowadays you can use LLVM instead and achieve portability, at perhaps a small cost in efficiency.