2801
CPU, RAM, I/O | TOC |
(I know some of my audience will think this chapter is a little dry, but important stuff happens in here, so give it a read anyway.)
Mr. Mori turned back to the projector.
"The 8080 derives from their initial 8008 CPU, which is based on the Computer Terminal Corporation's Datapoint series controller implemented at lower scale integration -- the central processor is on a printed circuit card rather than a chip.
"This is the published register set for the 8080:"
"The 8080 has 7 sort-of general purpose 8-bit registers plus a dedicated status register that can sometimes be treated in pairs as 16-bit registers -- sort-of. It also has a 16-bit stack pointer that you can use to keep track of data in memory, and a 16-bit instruction pointer that keeps track of which instruction the CPU will perform next.
Cyndy raised her hand.
"I'm sorry to ask, but I'm not quite sure what 8-bit and 16-bit mean. Is that the number of binary digits the register can, uhm, hold?"
"Correct. Barry, what's the biggest number register A can hold?"
"Signed or unsigned?"
"Yes."
"Unsigned, 0 to 255. Signed, wait. Does the 8080 run in two's complement?"
"Yes."
"Signed values range from minus 128 to 127."
"Very good. Chuck, what's the range for H and L together as a 16-bit pair?"
"Uhm," Chuck stalled with a lopsided grimace. "From zero to two to the 16th power minus one for unsigned numbers, and," he slowed, but continued carefully as if he were checking facts in his mind as he recited them, "for signed, minus two to the fifteenth to two to the fifteenth minus one."
1,024
2,048
4,096
8,192
16,384
32,768
65,536
I watched over Cyndy's shoulder as she started writing out powers of two from 512 in a margin. Hec and Rick noticed, too.
"You're having trouble remembering these numbers?" Mr. Mori asked with a patient smile.
"Thirty-two thousand something and sixty-five thousand something."
There was a bit of snickering from various members of the class.
"Close enough for now," Mr. Mori nodded. The snickering quieted.
Cyndy interjected, "Okay, the exact ranges are 0 to 65,535 and minus 32,768 to 32,767, right?"
Eleven pairs of eyes and the heads that owned them turned and stared.
Bob complained, "If you knew, why did you ask?"
Hec replied for her. "She just worked it out right now."
"Once Chuck confirmed it for her in the power of two forms, she understood, I think. Right, Miss Mills?"
"Yes, Mr. Mori."
"Remind the class what this means, Rick?"
"Why not ask Merry?" Rick grumbled under his breath, giving me a sideways look before answering. "Eh, when you put two registers together, uhm, that'll increase the number of columns, and the maximums are based on the power of two to the number of columns, adjusted because of zero or because of the minus range. Did I get that right, Joe?"
"Yeah, that's the way I understand it."
Rick tilted his head back without looking at me.
"Mary?" Cyndy questioned under her breath.
None of the three of us in hearing range elucidated.
"Everybody comfortable with that?" asked Mr. Mori.
There was a chorus of yahs.
"Okay, moving on, A is the register that is primarily used for recording arithmetic and logic results. It's called the accumulator because results tend to accumulate there. But for 16-bit arithmetic, especially address arithmetic, the H:L pair can often be used. B:C and D:E can hold addresses for moving data around, and H:L can also hold addresses -- point to operands for more general purposes than just moving data. None of which probably makes sense yet, but it will when we look at the instruction sets.
"One particular 8-bit register doesn't have a name because it can't really be directly accessed. It can't be used as a general purpose register because it records the condition, or status, codes -- information about the most recent operations, such as whether a carry or borrow has occurred in arithmetic; whether the current result is zero or not; whether it has the most significant bit, the sign bit in two's complement, set or not; and whether the current operation resulted in even or odd parity. We'll get to which operations set what, when, and what it all means later.
"The condition codes are paired with the accumulator as the program status word, PSW, because they usually represent the current status of computation in the CPU. The entire PSW is basically accessed when you save it or restore it with a push or pop.
"And pushes and pops in the 8080 happen in pairs -- the register pairs shown."
I raised my hand.
"Yeah, Joe?"
"I don't think 16 bits is enough for floating point numbers, is it?" I asked.
"Depends on the floating point precision, but if you are talking about Hec's calculator, no, it's definitely not."
Hec had a programmable Hewlett Packard calculator his dad had given him in payment for some work he had done for his dad. I think it was his dad's old HP-65. It had the magnetic card reader, and he had been studying how to program it.
He volunteered, "The user's manual says it uses 64 bits, I think."
"That sounds right," Mr. Mori continued. "But this cheap 4-function calculator on my desk probably uses just forty bits. Supercomputers might use 128 bits or more."
"What about the 8080?" asked Bill.
"The 8080 doesn't do floating point unless you program it to, so it depends on the floating point software. But 32, 40, and 48 bits are common sizes."
"Is the 8080 slow?" Karl asked.
"Depends on the software. It's likely faster at floating point than many calculators. But some calculators actually use the 8080, often at slower clock speeds than a computer would. The others we will look at today, also, either have been or could be used in calculators."
Cyndy commented, "The total number of bits in the 8080's data registers isn't enough to do floating point in registers, is it?"
"That's right," Mr. Mori nodded, "pretty much. 32-bit floating point -- you might fit one operand in B:C and D:E together, but it might not help."
"So floating point numbers have to be stored in RAM, right?"
"Good point. Not just floating point, but strings of text and many other kinds of complex data will be stored in RAM, and pieces of them will be brought into the registers to work on.
"By the way, when you store 16-bit quantities in memory or load them from memory on the 8080, the less significant byte is at the lower address. You may feel that is backwards. I think so. But Intel thought it would save them some critical nanowatts or nanoseconds or development time or something, and, as long as the CPU is consistent with itself, the CPU doesn't care what humans think."
"One more thing, some of the registers in the 8080 tend to have specific purposes, according the instructions that operate on them, and are less useful outside those purposes. That is, there are certain operations that can only be done with certain registers. That allowed Intel's engineers to supporting more functionality using fewer of the available op-codes.
"And we want to talk more about instructions and addressing when we examine some actual code. But I think we want to get a look at the register sets of some of other CPUs that are reasonably available first."
He reached for his box of transparencies.
I looked over at Cyndy's notes again and grinned. "Your notes are much better than mine."
"You want to copy them, Joe?" She was being coquettish again.
"That's okay. I'm not much for taking notes."
"Yeah, Joe doesn't really need to take notes," Rick commented. "He has a mind like a trap. Sometimes it's really hard to get him out of that trap, too." He grinned sardonically.
I gave him a lopsided grin. "I can't argue with that."
"You can compare notes with me," Hec offered.
"I'm not interested, Hector."
Mr. Mori cleared his throat, and the conversations at all the lab tables died down.
"Here's the register set for the 6800."
Karl snorted. "That's a register set? What can you do with that?"
Mr. Mori chuckled. "Compared to most minicomputers and mainframes, the 8080 has a pretty limited register set. Yeah, you could accuse the Motorola team of trying to find a minimal useful register set, and I think they got close. But if you think this is too few, wait until we get a look at the 6502 and the 9900. Anyway let's look at what the 6800 has to offer."
Chuck said, "It has a stack pointer, like the 8080."
"Right. We'll look at the differences later."
Cyndy said, "The program counter is the equivalent of the instruction pointer, right?"
"Very good. Maybe I can let you guys teach the class." Mr. Mori grinned.
Bill volunteered, "The index register X would be like the 8080's H:L pair?"
"Right. But the 6800 handles indexing differently -- which we'll discuss more when we discuss operators and addressing. And the differences do make up somewhat for the dearth of registers."
"Two accumulators?" Mark asked. "That's not so minimal?"
"Having two accumulators allows one to be used as a counter or such while the other is accumulating results in a loop of repeated operations."
"I could see that," Mark nodded.
Barry asked, "Can A and B be paired for 16-bit math?"
"Sometimes it's useful to use them that way, but Motorola didn't provide a single instruction that will do it in the 6800. I wish they had."
(In the real world, Motorola was working at the time on MACSS, which gave us the 68000 -- and 6809 as a byproduct. The 6801, which would fix several small issues like this with the 6800, but retain compatibility with the 6800, would come out of the work on the 6809, but would end up released before the 6809. And if you are interested in such things and haven't looked at the 6805, you should.)
Rick glanced over at my notes. "Joe thinks CCR is the 6800's PSW."
Mr. Mori raised his eyebrows. "What do you think, Rick?"
I added a couple of marks to my notes where Rick could see them.
"Condition codes, program status, sounds like the same thing, uhm," he check the marks, "but without the accumulator?"
"That's why I don't let people copy my notes," I grumbled.
We exchanged lopsided grins.
"Right. There's also a bit in the 6800 condition codes that is not present in the 8080 condition codes, used to disable some interrupts. And we'll talk more about that later, too."
Out of the corner of my eye I watched Cyndy checking my notes, then Ricks, and then Hec's.
"We'll need to talk more about accessing the condition code register on the 6800 later," Mr Mori continued.
"And this next part is actually about addressing modes, but this is something that is relevant in considering the dearth of registers -- the 6800 has a direct page shortened addressing mode that treats the first 256 bytes of RAM as special locations in memory, making them almost as useful as registers, but not quite." He swapped out transparencies:
"We almost might want to call the first 256 bytes pseudo-registers."
Frank laughed. "That's a lot of almost."
"True," Mr. Mori replied with a wry grin. "But I don't want to spend much time on why I say almost until we talk about addressing."
Barry asked, "Would this direct page be a good place to work on floating point numbers?"
"Good question. I'm not sure I know a good general answer to that. One problem with that would be what would happen if a program doing floating point calculations got interrupted and some other code tried to use the same locations."
Barry nodded. "I could see that screwing up calculations."
"We need to talk about saving stuff before you use it, too, later.
"Oh, and while we are talking about data in memory on the 6800, it stores and reads 16-bit values in memory with the more significant byte first, which I think would get my eyes crossed less. I just want y'all to know."
He sighed.
"But right now I think we have enough time to talk about the registers in the 6502 before we take a break." He swapped transparencies again:
There were noticeable vocalized expressions of surprise from various parts of the room.
"I think you can see the influence of the 6800, which isn't really surprising, since the team that designed the 6502 is basically a group of the 6800 team engineers that left Motorola to do so. They worked on a shoe-string budget, and the design is rather minimal, but quite powerful."
Frank said, "So the stack is located at a specific place, and is limited in size to 256 bytes. That might be reasonable. But, ..."
I pursed my lips. "Two index registers looks good, maybe a good tradeoff for one of the accumulators. What's the trick for getting 16-bit addresses out of them?"
(Yeah, Joe is a bit ahead of me, catching on to this so quickly. But the whole class is a bit ahead, too.)
"X and Y are used in different ways, which we will talk about when we talk about addressing modes. But, yeah, the 6502 provides powerful addressing modes which compensate for the width of X and Y and even somewhat for having so few registers.
"In the 6502, the first 256 bytes of address are called the Zero Page. They are very clearly intended to be used as pseudo-registers, and are supported in that use by the instruction set and addressing modes. And the 6502 instructions are a bit more cycle-efficient than the 6800 instructions -- a bit faster, so that the 6502 can keep up with or even beat the 6800 and 8080 at the same memory speeds.
"And, just for the record, the 6502 is, like the 8080, little endian. It stores the less significant byte first for 16-bit values."
Mr. Mori took the transparency sheet off the projector and turned it off.
"We're too close to the bell to pick up the COSMAC 1802 and the TI TMS9900, so I think I should let you guys check your notes, discuss them in your groups, and ask questions until the bell."
Not that I should have noticed, but Cyndy was looking a little uncomfortable.
I leaned against the table and stared at the whiteboard, and subvocalized to myself, "I wonder if it would be too way out there for any other girls to decide to join our class, too."
It shouldn't have been loud enough for anyone to hear. But Rick responded, beneath his breath, "I know who you're thinking of. Wishful thinking man."
Cyndy shouldn't have been able to hear, either. I wasn't really watching her, but I saw, out of the corner of my eye, her face show a reaction I couldn't read.
Rick said out loud, to no one in particular. "Jokes aside, should we compare notes?"
Cyndy relaxed a bit, and we did exactly that.
While we were comparing notes, Bob came over and grabbed an unused chair and tried to get Cyndy's attention.
"Hey, anytime you want to join our table, Scott's willing to give up his chair."
"Hey!" Scott picked up his books and moved them to the neighboring empty table. "Cyndy, you can join me at my new table."
Cyndy replied, "Guys, give me a minute and I'll come over and look at your notes."
Scott grabbed his notes and came over and Bob went back for his, and pretty soon the whole class was gathered around our table comparing notes -- and joking around a bit, of course.
When the bell rang, Cyndy excused herself and left, and the rest of us broke up for the ten minute break.
I wandered up to the shelves at the front of the room, and picked up the datasheet for the 6800, somewhat at random. Rick and joined me, picking up a copy of Radio Electronics and flipping through it.
Some of the other guys joined us, as well. Harvey, in particular, seemed to be searching for something.
Rick showed me an ad for the SWTPC 6800 computer and the terminal they were selling at the time. "I could pay for this with a couple of month's wages."
"Looks interesting." I looked over his shoulder as he continued thumbing through the magazine. A page advertising the MEK6800D1 evaluation kit popped up.
"Wait." I grabbed a pencil and piece of paper and wrote down the contact information for Motorola, then we started looking for ads for evaluation kits for the other processors Mr. Mori had mentioned. We had contact information for Motorola, MOS Technology, Intel, RCA, and TI by the time the Cyndy came back.
Cyndy didn't say why, but remained at our table.
TOC | Next |