Monday, August 3, 2026

[MARK00] 3809/2801: 6502 Indexed Addressing, Including Memory Indirect

EDIT MARK record 00
Read the current version at: 
https://joelrees-novels.blogspot.com/2026/08/3809-2801-6502-indexed-addressing-including-indirect.html

2801
6502 Indexed Addressing, 
Including Memory Indirect

ALUs, Register Indirect Review, 
Role Playing the 6800

TOC

"Okay, Harvey, you said the 6502 has two index registers, but they are only eight bits wide, right?"

"That's what my notes say." 

"And, Pete, you mentioned a 16-bit index base constant part for the instruction."

"I thought it might be a possibility."

"What benefit would it have?" 

"When you know an array's address, it could start anyplace in memory, as opposed to the 6800's 8-bit constant part. But the index register would still limit the array's width." 

Mr. Mori put a transparency on the projector. 

"Something like this?" 

Mr. Mori stopped and looked at the diagram. "Oh, wait. The 6502 assembler syntax uses parentheses to mean indirection, and this is going to be confusing. Let me fix this."

He erased the punctuation in question: 

Pete said, "So I guessed right?" 

"I guess you did. What else is different about it, different from the 6800 and 9900?"

"Little endian," Harvey said.

"Yep. The 6502 puts its low byte first, like the 8080 and the 1802." 

Bill asked, "Are X and Y interchangeable?"

"Sort of. There are some differences in which instructions and addressing mode can be used with which. We'll talk about it in a minute or so, but Y indexing is not supported for some single-operand instructions. File that fact away in your brain somewhere, and we'll come back to it."

Ted raised his hand. "Single-operand instructions means read-modify-write?"

"You're trying to confuse everyone."

"Sorry."

Mr. Mori grinned. "Just kidding. You're right and we'll talk about that later, too. Probably not today." He paused, then asked, "Can anyone think of a way of getting around the width limitation?" 

I suggested, "Use the middle of the array for the constant base address?" 

Mr. Mori nodded. "Can you tell us how to do that?"

"Uhn --"

While I was thinking, Frank raised his hand.

"Frank?"

"If the array is larger than 256 bytes but smaller than 513, provide one routine to point into the low half, and provide another to point into the high half. Then you can figure out somehow which half you're needing to point to, to choose which routine to use."

"Very good, and we'll talk about how to actually do that later, as well, because knowing how can be useful. Not today, I think. And there's another way that involves modifying the constant base in the actual op-code at run-time, but I do not want to teach you that."

"Why not?" Karl asked.

Cyndy said, "You might accidentally modify the wrong part of the instruction?"

"That's part of it," Mr. Mori agreed. "What else?"

Frank said, "You might modify the constant part of the instruction once, and something might interrupt the code, modify it again, and then somehow fail to restore it before the original code finishes accessing the array, which would really confuse the code." 

"Excellent. And the guys who designed the 6502 knew that could happen, so they gave us another way that doesn't require separate routines for each 256 bytes of the array, but I want to talk about that after I talk about something else." 

He picked up another transparency. "I need to erase the parentheses on this one, too." He did so and replaced the one on the projector. "Just to be complete, what does our 16-bit constant part and 8-bit variable part mean for arrays when you don't know where an array begins until the program runs?" 

"If the base address is in the index register and the 16-bit part in the instruction is the offset, that's pretty much useless," Karl complained.

"Why so?"

"How often are you going to have an offset larger than 256 when the array starts in page zero?"

"Good point. The architects of the 6502 knew this as well, probably from programming the 6800, and they provided a short indexed mode." Mr. Mori picked up another transparency, fixed it, and swapped it in.

"So you can put the base address in the index register and only use one byte for the offset. They were saving space in the op-code table, so the Y index register can't do this except for two instructions, load X and store X. And I'm not sure whether the guys who designed the 6502 did this for some reason or it just worked out that way, but this address mode wraps around in page zero, so you'll need to remember that, too."

I asked, "So the entire array has to fit in page zero?"

"If it doesn't, you'll have to use the 16-bit offset form for the parts that go beyond, which can get really awkward, or just use the 16-bit offset form for the whole array."

Bill said, "I think I can see that." 

"Of course, we can also do 8-bit constant base with 8-bit variable index with this addressing mode, as we have discussed before. Gotta fix this one, too." He did so, and swapped another transparency in.

Karl said, "And this still limits the useful size of arrays."

(Surprisingly, there are a lot of useful applications for microcontrollers that don't actually need any more than 256 bytes for any particular array, or even for all arrays. In fact, one of Motorola's corporate customers pointed this out to Motorola sales engineers, probably about the time I and my real-life classmates were beginning the Industrial Electronics class in the real world. And Motorola would respond by designing the 6805, which would be appropriate to describe as a half of a 6801 -- almost literally. Or maybe half a 68HC11. Only the accumulator A, only an 8-bit X. Some bit handling instructions not in the 6800 or 6801. But the 6805 and its descendants would become one of Motorola's biggest cash cows in your reality. Some analysts would estimate that descendants of the 6805 outnumbered all other microprocessors and microcontrollers delivered in the early 1990s, before ARM ..., but I'm getting way ahead of the story again.)

"If we had some way to work on all 16 bits of an address in memory and then use the result as an address, it would help, right?"

Karl grunted agreement. "I don't see any way to handle generalized arrays with just what you've described, except by what you said, multiple access functions or run-time self-modifying code. Is there a 16-bit index register hidden away somewhere?"

"That brings us to two more addressing modes in the 6502 which are called memory indirect addressing modes."

Bill said, "Indirecting from memory would be like indirecting through the 9900's working registers?"

"Sort-of kind-of pretty much like, the way I see it." 

Harvey added, "So X and Y are only eight bit, but the 6502 can use 16-bit addresses directly out of memory?"

"Directly indirectly." Mr. Mori grinned at his own joke. None of us students really got why it was amusing, just yet.

"Let's look at one of these addressing modes." Mr Mori swapped transparencies. "The first one is a kind of extension of the short indexed mode, but what you are indexing in the direct page is an array of addresses that the 6502 can load into its address buffer. You might use it something like this:" 

 

"Note that we are now scanning the list of addresses, not the string, with the index register. Maybe I should have shown the address buffer in this, but that might not be exactly accurate. Hmm. Let's give it a shot." 

Karl stood up and said, "So there is a 16-bit address register hidden in there!" 

Mr. Mori reworked part of the diagram while we watched. "Yeah, sort-of. Whether it's an actual 16-bit register or not, I don't know. But it's as if there is one there." 

 

Karl sat down as Frank said, "So you with this we can look at the length byte, but how would you scan the string?"

I suggested, "You could have a 16-bit variable that's an array of one, that you can copy the address to, and do address math on that like we did on the 6800, and then use this indirect mode on the array of one?"

"Might work, but what happens to X while you're doing that?" Mr. Mori asked.

Ted said, "I think it gets walked on."

I asked, "Can you use this mode with Y so you can keep X pointing to the array?"

Mr. Mori said, "You guys are thinking. Great. Y does have a little bit different use. Let's look at it." He swapped transparencies. 

"Oh, let me put that address buffer in here." 

He started reworking one part, then stopped again for a moment. 

"Except there must be two virtual 16-bit buffers, according to the timing charts. Or they figured out a way to reuse it pretty efficiently. Hmm." 

He reworked another part, as well. 

"I'm not sure, as you may have heard me just telling myself, whether the 6502 adds Y to the same address buffer it used to bring the address out of P, or whether there are two separate buffers. No guarantees on the actual accuracy of this diagram. Either way, hopefully, you can see something of how it works in this diagram."

I said, "So P in this is like Rick's and my X16 variable --"

Rick said, "That was your X16 variable, but, I think you're right. It looks like we can do math on that in memory, and then it can be used directly as a base address with Y as the index. Which overcomes the width and location problems like in the 6800, but without having to load and store the 16-bit X."

Bill said, "So, we could load an address from a table of string addresses indirecting from X, then move that address to P and use P to scan the string." 

Harvey said, "I think you'd use the X indirection to do something like checking the length of these strings, and if the length is in the right range, use regular indexed instructions to load the pointer to P, where you could use the Y indirection to scan the strings." 

Mr. Mori said, "Harvey, do you want to try writing some code to do that?"

"Uh, not really."

Mr. Mori picked up the marker from the whiteboard tray. "How about if Bill helps?"

Bill and Harvey looked at each other doubtfully, but Bill stood, and then Harvey stood, and they went to the whiteboard. Harvey picked up the marker.

Harvey said, "Do we put the address of the array of string pointers in X?"

Bill said, "Let's use the address for the constant part, like the example shows."

Chuck asked, "Could it go either way?"

Mr. Mori said, "Let's wait to think about that."

Harvey wrote

  LDX #4    ; 3rd string is offset 4

Bill said, "We need to get the length to look at it."

Harvey hesitated, and  then wrote

 LDA (N,X) ; N array is in page 0, get length of string

"Then what?" Bill asked.

Hec said, "We don't really know how this part works."

Mr. Mori said, "Just write something."

Harvey wrote

 (something) 

Everyone laughed, but Mr. Mori said, "Good." 

Bill said, "Assuming we can proceed, we need to load the address into P.

Harvey said, "And we do that byte-by-byte." He wrote,

 LDA N,X ; low byte of address
 STA P ; P is in page 0
 LDA N+1,X ; high byte of address
 STA P+1

Karl said, "Is that legal? I can see P plus one, but N+1 --" and he trailed off. 

Chuck said, "Bumping the constant for the base by one probably has the same effect as bumping the variable X  by one, doesn't it?" 

Mr. Mori said, "It does."

"Okay," Bill said. "We need the offset into the string."

"Put it in Y?" Harvey suggested, then followed his own suggestion.

 LDY #3 ; 3rd char after length

Bill said, "I guess we're ready to do whatever it was we were going to do."

Harvey said, "That was op B, wasn't it?" and wrote,

 opb (P),Y

"Did I get the parenthesis right, Mr. Mori?"

"That's the way I understand the syntax to work. Parentheses indicate indirection." Mr. Mori replied.

Mark said, "So the 6502 is carrying the concept of page zero as a bank of pseudo-registers a bit farther than the 6800."

"Thank you for pointing that out." replied Mr. Mori. 

I said, "But we still aren't really scanning any strings. We need some way to repeat things."

"True. Anyway, once you understand how these two modes work here, I think you'll be able to think of more ways to use them." 

Karl said, "I don't really see how modifying P is significantly different from modifying the address field of an instruction. If you modify P and then something interrupts and modifies it again before you can use it, you're still going to be using a wrong base address."

Mr Mori said, "Good point. One difference is, as Cyndy pointed out, that you are less likely to overwrite actual instruction object code with P. Another is that you can collect P with other variables that need to be swapped out and restored when an interrupt happens. It makes it easier to manage what needs to be managed."

Karl set his mouth in thought. 

Mr. Mori let us think some more before continuing. "Now there's one more mode, and I want to mention it. It's a mode only for jumps, that they call absolute indirect in the docs. An absolute jump moves program flow to the 16-bit address that the instruction specifies. An absolute indirect jump moves program flow to the 16-bit address that is stored at the address specified in the instruction."

Barry said, "So, the absolute jump is like load PC immediate, and the absolute indirect jump is like load PC absolute?" 

Scott and Bob groaned, but Mr. Mori said, "That's another way of looking at it, but I'm afraid some of our students will be confused.

Mark stood up and went to the whiteboard. 

Mr. Mori said, "Looks great. There is a bug in this instruction, however. When the instruction specifies an address with a low byte of 255, it grabs the low byte of the new PC from the proper place, but then wraps the address around to get the high byte instead of incrementing."

"So we should never give it an address that ends in hexadecimal $FF, then," Mark said. He wrote in a note next to address 2101, "Don't use JMP (0XXFFH). No 255 in low byte.".  And he put the marker back and sat down.

"Correct."

Mr. Mori shut the overhead projector off, leaving it in place to cool.

"We've been burning the brain oil, so let's shift gears and look at your letters of inquiry." He moved an opaque projector in beside the transparency overhead projector.

"About your letters of inquiry, Ms. Wilson informs me that she will not allow Cyndy and Joe to type anybody's letter of inquiry for them in the school's typing lab. I must say that she has convinced me of the folly of the plan."

There were a few scattered groans and complaints, along with some "Of course." and such.

"On the other hand, she did have an another plan, and I think it's a better plan. She thinks she might be willing to hold the computer lab open after school for you guys to go over in small groups, and she can coach you and then let you type them up yourselves. But she needs to check with administration first."

Responses shifted a bit more to the positive.

"I think most of you realize that typing is a useful skill when you're working with computers. So if she gets approval, this could be a good opportunity. But you must all understand that, if you do this, you must treat the typewriter lab equipment with respect, no less respect than our electronics lab."

Mark said, "No playing football with the typewriters, Karl."

There were scattered chuckles. 

"Hey!" Karl objected. "I know how to throw a typewriter respectfully."

More chuckles. 

Mr. Mori gave us an indulgent frown. "Getting yourselves kicked out of school would leave us short of students again. Don't do that." 

There was scattered laughter.  

Rick and Hec shook their heads.

Cyndy's eyes grew wide with concern.

I gave it all an eyeroll.

"Guys," Cyndy exclaimed, "Think of what Ms. Williams would say if she heard this. She'd probably change her mind."

The jesting suddenly stopped.

Karl coughed. "Sorry, Cyn. Just kidding."

"'Cyndy', to you."

Karl ducked his head in apology. 

"The problem with jokes is when they suddenly quit being jokes," Mr. Mori's voice was sober. "There are parts on those electric typewriters that I'm sure some of you will be tempted to get your fingers into or treat like balls. I don't want to have to be this way, but I will have to have promises from everyone who goes to behave yourselves. I may even need a permission slip from your parents."

Mark said, "I guess that was partly my fault, too, leading off like that. Sorry, Karl. Sorry, guys." 

There were general murmurs of agreement, and Mr. Mori let them die down. 

"So, Joe," he shifted gears. "Do you have your letter with you?" he asked as he turned the opaque projector on.

Cyndy gave me a querying look, and responded before I could. "I have mine typed up." She slipped it out of her notebook and handed it to Mr. Mori while I got my copy from the typing class out.

He looked puzzled, and accepted Cyndy's, but turned to me. I handed him the letter I had typed at school. 

Rick glanced over at me. "You kept a copy, then. Smart move." 

Mr. Mori looked them both over, then said, "It looks like you both did a bit more editing before typing these up yesterday."

"Ms. Wilson made some suggestions," Cyndy explained before I could.

"Nice of her."

Cyndy was still querying me with her eyes. 

"We've been asked to be careful about showing students' actual addresses and phone numbers in class, do you mind if I mark out your address and phone number and show this to the class?"

"No problem, either way," I replied. "But, for the record, that's not what I actually sent."

"Sent?" Mr. Mori gave me a quick look.

"I guess I got impatient last night." 

He blinked at me. "You have a typewriter at home?"

"Dad does, but I sent it handwritten. I was careful to make it legible."

Mr. Mori looked non-plussed. "Administration wants copies of every letter sent. I don't guess you made a copy of it?"

"Scratch copy in pencil, with mark-up," I said as I turned to dig into my notebook for the scratchwork, but Cyndy was holding a piece of paper up for me.

It was my turn to to give her a querying look.

"You might want this," she said, quietly, with a knowing smile.

I blinked and accepted it. 

It was my own writing, the letter I thought I had sent the night before. 

"What? How on earth?"

Cyndy smirked and kept her voice low enough only Hec and Rick and I could hear. "She said you didn't notice."

"She --" I kept my voice low as well.

Mr. Mori watched our exchange with interest. 

"Writes fast. And accurate." 

I gave an embarrassed laugh and covered my eyes with the letter for a moment before handing it over to Mr. Mori without comment. 

"Secrets?" Mr. Mori asked. He looked at Hec, who shrugged.

"Well, good for you, you did make a copy. Does not look like pencil, though. And I don't see any mark-up."

I coughed. "I'm going to have to blame this one on my study partner."

"Good for you, Cyndy, although you might have gone so far as to encourage him to be more patient."

"Hec and I studied at my house last night." 

"Rick?"

"Different study partner," Rick said. 

Mr. Mori gave the four of us a look and said, "Curiouser and curiouser."

None of us volunteered more information.

He chuckled. "Well, let's take a look. I'll go ahead and mark out your address and phone number." 

He compared mine with Cyndy's and said, "I think I'll start with Cyndy's after all." 

He marked her address and phone number out and put her letter on the platen and adjusted the projector. "Okay, she uses standard greeting --"

"What happens," asked Harvey, "if they aren't sirs?"

"'Dear Sirs' is standard greeting. They won't be upset. Odd-ball greetings will not impress anyone."

"Oh."

"She identifies herself and our school, and our class. She gives my name as the teacher and the school address and contact information we showed you yesterday.

"Then she explains her interest in the 8080, that we will be studying it in class. It's a little bland, but that's actually good. 

"And she asks for information on how to obtain documentation for both the microprocessor and its support parts. And she closes. 

"Clean grammar, no attempts to dress things up. No particular reason to refuse the request. She will likely get some standard advertising material, a list of parts that she can request information about, and a standard order form for the datasheets." 

He looked around the class. "Any questions?" 

Nobody thought of anything immediately.

"Okay." He took Cyndy's out and gave it back to her, and replaced it with my typewritten inquiry, after marking out my address and phone number.

"We see Joe has done essentially the same here. You'd think they typed these up together yesterday in typing class." He chuckled to himself. "But you can see some differences in expression. Which do you guys think is more likely to get a good response?"

We spent a minute or two critiquing Cyndy's and my different ways of wording things.

"Okay." He gave me back my typewritten letter, then marked my phone number and address off the handwritten letter and put it on the platen. "In this version, Joe is explicit about his interest in the 6800. He isn't just interested in it for class, he thinks there are advantages. He even goes so far as to name all the microprocessors we are studying. 

"I'm not sure that's a good idea. I'm not sure it's a bad idea. It is something of a sales pitch approach, however, and we need to be aware that it may be received as insincere. It may also be received as ambitious."

"The inquiry itself, he's becoming more ambitious. In addition to information on the CPU and related parts, he's asking for information about development tools.

"Now, whoever handles this at Motorola might not think about a student wanting to know about development tools. The development tools aren't cheap, and they may wonder whether Joe understands that. I do think they are more likely to reply with some information about development tools, since he asks.

"But he does sound like a kid who's asking bigger questions than he realizes. Sorry, Joe."

I nodded. 

He continued, "On the one hand, I don't recommend Joe's approach in general. Smaller companies without secretary staff, an engineer may get the letter and tend to set the inquiry aside to respond to when he has more time to think about it. On the other, I'm not sure it would hurt with Motorola, they are a fairly large company, and it is more likely the letter will be handled entirely by a secretary. I guess we'll see." 

He took my other letter off the platen and gave it back to me. "Harvey, are you willing to let us see yours?"

"Uh, sure." He already had his out, and handed it to Mr. Mori. "No problem if you mark out the address and phone number."

Mr. Mori scanned it. "Okay, here we see some differences." He marked out the personal information and put Harvey's letter on the platen. "Harvey is sending his to Apple, which is a company selling computers, not a company selling microprocessors. Well, selling the mainboard. So what he is asking for is comprehensive information on what the mainboard includes, and what options Apple sells for it at that apocalyptic price, which, low as it is for a computer that is almost complete, is enough to buy a pretty decent used car."

He looked up. "The letter is okay, but you guys should know. The apocalyptic price does not include the TV used as an output device. It also does not include the keyboard, power supply, or a cassette interface. So there is some assembly required. And Apple is selling them so fast they really haven't had time to print up a lot of the documentation materials that they might be willing to send to students.

"I don't want to discourage you, Harvey, but you might do better just sending an inquiry to MOS Technology about their KIM-1. It doesn't output to the TV, but it's much cheaper, and you can ask about the 6502 and peripheral parts at the same time. You might want to reference Joe's letter." He handed Harvey back his letter.

"Do you mind, Joe?" Harvey asked.

"No problem." I passed my second letter over to him, and he started copying from it.

Rick said, "Harvey, can I check your letter for ideas? I'm going to be sending mine to Southwest Technical Products, to ask them about their 6800-based computers."

"Sure." Harvey passed his letter to Rick. 

Mr. Mori asked, "Anybody get a letter to RCA or TI?"

Hec said, "I've got one to send to RCA, but it basically looks like Cyndy's."

I said, "You might want to take a look at the COSMAC manual over at OC before you send it."

Hec looked thoughtful. "Maybe so." 

Mr. Mori looked at Ted, but Ted shrugged and didn't say anything.

"Well, we're close to the bell. I'll let you guys clean up your notes or work on letters of inquiry."

I went to the front of the room and looked through more magazines while Rick worked on his letter. I found an ad for the MEK6800d1 and read it before taking it back to show Rick.

Hec read a little over Rick's shoulder and then went back to the magazine stack and thumbed through more magazines, finding an article on the COSMAC ELF, which he brought back to the table. Cyndy read over Hec's shoulder. When Harvey brought my letter back and Rick gave him his back, he saw what Hec and Rick were looking at, and went up and thumbed though more magazines, finding an ad for the KIM-1.

We passed the magazines around, and Barry dug up an ad for Intel's SDK-80 in another magazine. No one was able to find ads for any similar devices for the 9900.

While we were digging around in magazines, Mr. Mori was talking with Chuck. 

After class, Mr. Mori snagged Ted to talk. Ted seemed hesitant. 

Cyndy and Hec left together, deep in discussion. Rick and I headed out, and met Sapphire outside Rick's next class, and Sapphire and I walked to the typing lab together. 

"Mom suggests that we should study where others are around."

"Oh?"

"My leaving early for your seminary seemed to worry her."

"We'll have to see what she feels comfortable with, I guess."

"But there are things I need to ask you that I won't feel comfortable about if there are other people around."

"I'm sure we can figure something out."

We stayed outside the classroom, holding hands and not saying much until Cyndy approached, and we went inside. 

 

TOC
Next
Where it starts

Copyright 2026 Joel Matthew Rees



[CUTTING ROOM FLOOR] 3809/2801: M6800 EXORcises to 6502 Indirection

Scraps from the cutting room floor,
from around M6800 EXORcises to 6502 Indexing

This is the author's record of some of the stuff that got discarded; 
taken out of order, 
it does not tell things hidden things that happened,
or indicate directions the plot will take, etc. 

More than what is here,
you should want to read the story,
which begins here:  
https://joelrees-novels.blogspot.com/2025/09/3809-2801-tale-of-mcus-and-time-part-1-2801.html

2801
Terms of Engagement
Cutting Room Floor

M6800 EXORcises


TOC


"We've been asked to be careful about using students' actual addresses and phone numbers in class, so I'll mark them out." He did so and put the letter on the opaque projector. 

He commented on my letter and asked the class for comments and questions, and then he handed it back to me. "Looks good to send it like this. I hope you don't mind a little extra practice typing it again."

"No problem. I already sent it last night."

"Oh." He raised his eyebrows. 

He turned to the class and said, "I don't see anything on Cyndy's letter to comment on, so I'm not going to ask her to let me mark hers up." He handed it back to her. "I think you can send it like this."

"Anyone else with a letter of inquiry that you want comments on?"

Hec handed his to him, and he scanned over it. "Cyndy typed this up?"

"Yeah."

"Do you mind if I mark out the address, Cyndy?"

"Sure. It's okay."

After discussing some points on Hec's letter, he handed it back. "Sorry about marking it up, Cyndy."

"No problem."

Rick and several other students gave him hand-written letters to look over, and he offered pointers and handed them back. 

 

*******

"True. Anyway, once you understand how these two modes work here, I think you'll be able to think of more ways to use them." 

 He paused again, to let us think, before continuing. "Now there's one more mode, and I want to mention it. It's a mode only for jumps, that they call absolute indirect in the docs. An absolute jump moves program flow to the 16-bit address that the instruction specifies. An absolute indirect jump moves program flow to the 16-bit address that is stored at the address specified in the instruction."

 

********** 

"So, Joe, do you have yours with you?" he asked as he turned the opaque projector on.

Cyndy gave me a querying look, and responded before I could. "I have mine typed up." She slipped it out of her notebook and handed it to Mr. Mori while I got my copy from the typing class out.

He looked puzzled, and accepted Cyndy's, but turned to me. I handed him my typed copy of my earlier draft. 

Rick glanced over at me. "You kept a copy, then. Smart move." 

Mr. Mori looked them both over, then said, "It looks like you both did a bit more editing before typing these up yesterday."

"Ms. Wilson made some suggestions," Cyndy explained before I could.

"Nice of her."

Cyndy was still querying me with her eyes. 

"We've been asked to be careful about showing students' actual addresses and phone numbers in class, do you mind if I mark out your address and phone number and show this to the class?"

"No problem, either way," I replied. "But, for the record, that's not what I actually sent."

"Sent?" Mr. Mori gave me a quick look.

"I guess I got impatient last night." 

He blinked at me. "You have a typewriter at home?"

"Handwritten. I was careful to make it legible."

"I guess you didn't make a copy of that?"

"Penciled, with mark-up." I turned to dig into my notes for the scratchwork, but Cyndy was holding a piece of paper up for me.

It was my turn to to give her a querying look.

"You might want this," she said, quietly, with a knowing smile.

I blinked and accepted it. 

It was my own writing, the letter I thought I had sent the night before. 

"What? How on earth?"

Cyndy smirked and kept her voice low enough only Hec and Rick and I could hear. "She said you didn't notice."

I gave an embarrassed laugh and covered my eyes with it for a moment before handing it over to Mr. Mori without comment. 

"Well, good for you, you made a copy. Does not look like pencil, though."

I coughed. "I'm going to have to blame this one on my study partner."

"Good for you, Cyndy, although you might have gone so far as to encourage him to be more patient."

"Hec and I studied at my house last night." 

"Rick?"

"Different study partner," Rick said. 

Mr. Mori gave the four of us a look and said, "Curiouser and curiouser."

None of us volunteered more information.

He chuckled. "Well, let's take a look. I'll go ahead and mark out your address and phone number." 



******* Need to talk about coordinating queries 

"So we should never give it an address that ends in hexadecimal $FF, then," Mark said. He wrote in a note next to address 2101, "Don't use JMP ($XXFF). No 255 in low byte.".  And he put the marker back and sat down.

"Correct."

Mr. Mori shut the overhead projector off, leaving it in place to cool.

"We've been burning the brain oil, so let's shift gears and look at your letters of inquiry." He moved an opaque projector in beside the transparency overhead projector.

"So, Joe, did you bring a copy of your letter?" he asked as he turned the opaque projector on.

Cyndy gave me a querying look, and responded before I could. "I have mine typed up." She slipped it out of her notebook and handed it to Mr. Mori while I got my copy from the typing class out.

He looked puzzled, and accepted Cyndy's, but turned to me. I handed him my copy. 

He looked them both over, then said to me, "Do you mind if I mark out your address and phone number and show this to the class?"

"No problem, either way," I replied.

"We've been asked to be careful about using students' actual addresses and phone numbers in class, so I'll mark them out." He did so and put the letter on the opaque projector. 

"It looks like you did a bit more editing before typing this up."

"Ms. Wilson gave me some pointers."

"Good of her."

He commented on my letter and asked the class for comments and questions, and then he handed it back to me. "Looks good to send it like this. I hope you don't mind a little extra practice typing it again."

"No problem. I already sent it last night."

"Oh." He raised his eyebrows. 

He turned to the class and said, "I don't see anything on Cyndy's letter to comment on, so I'm not going to ask her to let me mark hers up." He handed it back to her. "I think you can send it like this."

"Anyone else with a letter of inquiry that you want comments on?"

Hec handed his to him, and he scanned over it. "Cyndy typed this up?"

"Yeah."

"Do you mind if I mark out the address, Cyndy?"

"Sure. It's okay."

After discussing some points on Hec's letter, he handed it back. "Sorry about marking it up, Cyndy."

"No problem."

Rick and several other students gave him hand-written letters to look over, and he offered pointers and handed them back. 


****

 

"I've arranged with Ms. Wilson to make typewriters available in the typing lab after school. They have correcting ribbon, so you don't have to type perfectly. But if you're confident you can use handwriting that doesn't cause the secretary and managers that will be reading your letters eyestrain, you can write them by hand, too. Just," he gave me another look. "Let me check them before you send them. And make a copy for me to refer to in case the companies you contact contact the school. And keep another copy for yourself."

 

FTR, from the reality chapter: "I pulled out my query letter and looked it over, and decided to add a few things to it, mentioning the other processors we were studying, and making my interest in the prototyping kit pricing explicit. I wrote it out by hand in pencil, erasing and rewriting until I thought my additions were clear enough, then hand-copied it with a pen."  

 

 

(Besides, it's a little hard to remember all of what happened so long ago.) 

 

 

 

 

 

(Descendants of the 6502, by the way, are still being used in new designs as I write this.) 


*******

constant base, 16-bit array anywhere in memory, but width limited, methods exist to get around width

variable base/constant offset must start in page zero -- mention direct page is page zero

mention instruction differences, unary (RMW) not available to Y

 

8-bit constant short form exists, but wraps around, and only for X index instructions plus LD/STX ,Y indexed  

 

indexed indirect for table of indexes in page zero (index half bytes wrap in page zero), X points to index in page zero

 

indirect indexed is for base address in page zero (base halves wrap), Y has offset

 

Mark said, "So the 6502 is carrying the concept of page zero as a bank of pseudo-registers a bit farther than the 6800."

"Thank you for pointing that out," replied Mr. Mori. "Once you understand how these two modes work here, I think you'll be able to think of more ways to use them."

We spent some time discussing indirection and byte order, letting the students who hadn't quite kept up catch up. I'm sure you've kept up okay, so I'm going to skip all of that. 

(Besides, it's a little hard to remember all of what happened so long ago.) 

 

 

is basically loading an immediate 16-bit value into the program counter. An absolute indirect jump, then, is loading the program counter from the 16-bit address specified in the instruction.


"If you hand-write the final copy to send in, write neatly enough that the secretary that reads it doesn't have to strain her eyes. I've arranged with Ms. Wilson to let those of you who want to try typing your own borrow typewriters with correcting ribbons in the typing class, if you want to do it that way. Either way, keep a copy before you send it, so we can refer to it. 



(Descendants of the 6502, by the way, are still being used in new designs as I write this.) 


 

*******

"Something like this?"

Pete said, "So I guessed right?" 

"I guess you did. What else is different about it, say, from the 6800 and 9900?"

"Little endian," Harvey said.

"Yep. The 6502 puts its low byte first, like the 8080 and the 1802." 

Bill asked, "Are X and Y interchangeable?"

******

"Okay, Harvey, you said the 6502 has two index registers, but they are only eight bits wide, right?"

"I think so." 

"And, Pete, you mentioned a 16-bit index constant part for the instruction."

"I thought it might be a possibility."

"What benefit would it have?" 

"When you know an array's address, it could start anyplace in memory. But the index register would limit its width." 

"Mr. Mori put a transparency on the projector.

 

"And there you are. Remember that the 6502 puts its low byte first."

"Little endian," Harvey said.

"Yep. There are some differences about which instructions can be used with Y indexed addressing and with X indexed addressing. You might not know what I mean if I say X indexed is provided for both unary and binary instructions and Y indexed provided for binary. But file that fact away for now." 

Ted raised his hand. "Unary instructions are read-modify-write instructions, right?"

"You're trying to confuse everyone."

"Sorry."

Mr. Mori grinned. "Just kidding. You're right and we'll talk about that later. "

He paused. "Can you think of a way of getting around the width limitation?" 

I suggested, "Use the middle of the array for the constant base address?" 

Mr. Mori nodded. "Can you tell us how to do that?"

While I was thinking, Frank raised his hand.

"Frank?"

"If the array is larger than 256 bytes but smaller than 513, provide one routine to point into the low half and another to point into the high half, and figure out somehow which half you're needing to point to choose which routine to use."

"Very good, and we'll talk about how to actually do that later, as well. There's another way that involves modify the constant base in code at run-time, but I do not want to teach you that."

"Why not?" Karl asked.

Cyndy said, "You might modify the wrong part of the instruction?"

"There's that. What else?"

Frank said, "You might modify the constant part of the instruction once, and something might interrupt the code so that it fails to restore it before the next time you try to access the array." 

"Excellent. And the guys who designed the 6502 knew that could happen, so they gave us another way, which we aren't quite ready to talk about yet." 

He swapped transparencies. "Just to be complete, what does our 16-bit constant offset and 8-bit variable base address mean for arrays when you don't know where they begin until the program runs?" 

 

 

After some consulting with each other and with the class, they came up with this: 



Once you see this, you may be able to think of other ways to use these two modes, but I think this is basically what they were thinking of when they chose the modes to support."


 

 

 

****** 

Rick said, "I think I should be, as well."

"Okay, okay." I stood up and  


"And if the constant offset from the instruction stream is only eight bits?"

"Then all arrays have to start in page zero and be less than 256 bytes in size?"

"It gets even stranger than that with some instructions." 

"Yeah. Let's talk about that." 

***** 

"Okay, Harvey, what's peculiar about the 6502?"

"It has two indexes, but they are both 8 bits wide?"

"That's one thing." 

"If the constant base address can be sixteen bits wide, we have the opposite problem from the 6800."

"How so?"

"A sixteen-bit constant base can put the array anywhere, and we'd be okay as long as the offset is less than 256. But that only works when we know where it is in advance."

"That's true. The 6502 provides this mode, and I understand that we can do with both X and Y. Would you be willing to diagram it for us?"

Harvey hesitated. "I guess I can give it a try." He approached the white board.

 

*** 

 

 

"Joe left the steps to add the two bytes out of the diagram. Is that confusing to anyone?"

Several of the guys raised their hands.

"Okay, Joe, do you mind if I take over for a bit?"

"Sure. I mean, no problem."

"Okay, we're going to role play the computer." Mr. Mori grinned and paused for effect before continuing. "When I call you, stand up. Joe, you and Rick remain standing. Scott, you're direct page memory location X16. But we need an actual address. Rick, what's the actual address?"

"I don't know. Ten, maybe?"

"Ten it is. Barry, you're location X16 plus one. What's your address?"

"Uh, eleven?"

"Okay, Bob, you're accumulator B. What do you have when the code starts here?"

"Four."

"Right. Karl, you're the index register, X. What have you got?" 

"N."

"We need a concrete value for N so Barry and Scott know what hits them." 

"Anything less that 65,536?"

"What do you say, Joe?"

"I have the impression that addresses above 32,767 get used for stuff, so maybe below that."

"How about 31,999?"

I shrugged "I think it would be okay, but we have to divide that into high byte and low byte."

Karl looked at Barry with a grin. "You do the math."

"Well, 32,000 divided by 256," He looked at Mr. Mori, who nodded. "Is a hundred twenty-five, so the high byte is 124."

Scott nodded. "And the low byte is 255."

"Okay. But you don't have those yet. What do you have?"

Barry said, "Something random?"

"Probably."

"Okay, I have seventeen."

Scott said, "I'll have a hundred seventeen." 

Mr. Mori said, "Now we need someone to be the carry flag. Mark?" 

"Okay. I'm random to start, too?"

"Yeah."

"No carry, then." 

"Okay, Joe, read the instructions."

"Store X at location ten."

Karl said, "Scott first?"

"Yeah."

"Scott gets one twenty-four." 

Scott said, "124."

"Barry gets two fifty-five."

Barry said, "255."

I said, "Now, add B from location eleven."

Barry said, "255."

Bob said,  "Four and two fifty five makes --" he stopped. "I can't hold anything bigger than 255, so it wraps around to three, with a carry, I guess?"

Mark said, "Carry." 

I continued, "Store B to location eleven." 

Bob said, "Three."

Barry said, "Three."

Mark said, "Carry unaffected?"

I said, "Right. Now load B from location ten."

Scott said, "One twenty-four."

Bob said, "One twenty-four."

Mark said, "Carry unaffected, still?"

I said, "Right. Add constant zero to B with carry."

Mark said, "Carry."

Bob said, "One twenty-four plus one is one twenty-five."

Mark said, "No carry."

I said, "Store B in location ten."

Bob said, "One twenty-five."

Scott said, "One twenty-five."

Mark said, "Carry unaffected, no carry."

I said, "Load X from location ten."

Scott said, "124."

Barry said, "3."

Karl said, "Man this gets boring."

Mr. Mori said, "It's a good thing CPUs don't get bored, isn't it?"

We all laughed.

Karl grinned. "Well, anyway, X is now 32,003." 

I said, "And we are finally ready to do whatever op-code C was, but it's in indexed mode, and the index byte is zero."

"Yay," Karl said, and we all laughed.

Mr. Mori commented, "I don't see a return instruction."

"Is that what makes code reusable?" Rick asked.

"If your code is constructed correctly," Mr. Mori replied.

"We haven't got that far yet," I apologized.

"That's okay. We'll get there. But this prepares us to talk about the 6502."

Rick asked, "Can we all sit down, then?"

"Sure." 

We all laughed and those of us standing sat down.


 

 

But what if we don't know the base address ahead of time?"

"You're going to tell us about it?"

"Give me a hand drawing this.  

 

 

 

 

 

************* 

Draw a picture of string with constant offset, 

then array in direct page with variable offset, 

then adding the offset to an index variable in memory


6502: 

introduce absolute index on X and Y, instruction limits, and direct page index on X, instruction limits and Y for LD/ST;

Motivate the 16-bit base address problem, introduce simple memory indirect and instructions that use it.

indirect indexed ([base,X] or [offset,X] points to list of addresses)

indexed indirect ([base],Y points to the operand  

absolute indirect jump only

 

***********************


 

 

I found the right section in the stacks just as a library assistant brought Rick over.

"IBM 370," I announced quietly.

"Mainframe," Rick replied, also quietly. He read a spine. "PDP-11." He reached for the DEC manual.

"I think that's a minicomputer."

"So not a microcomputer." His hand paused.

"Mmm." I nodded.


 

Sapphire waiting in classroom? Karl or somebody joking about Joey? Hold it off?


Chapter five, section one dot two, eh, page five dash twelve."

 

"We're going to have to see if we can meet you guys there, then. You think, Cyndy?" 

"Yeah, I think so."

"I get to come along?" Sapphire asserted.

"Saturday?" I suggested. 

 

"Addressing modes, instruction set, pointer operations, branch and jump, looks like it repeats a lot of the information in the Programming manual. Hmm." 

Rick's eyes met mine, but he didn't say anything. He looked back down and continued flipping through the pages. 

I looked back down and continued. "Addition and subtraction routines, multiplication and division, counting." 

I opened to section two and read without a lot of comprehension. 

"Alpha, beta, gamma. Well, I suppose, if it's a small number and fits in an accumulator, adding requires loading the number to be added to, adding the number to add to it, and storing the result."


I moved past the table of contents

 

"Hmm. This looks like an electronic cash register," I muttered as I flipped through the pages of the manual I had. "Instructions on how to use Motorola parts to put together a point-of-sale terminal, including the programs. Complete with bar code reader." 

Rick put the Programming manual down and shifted his chair so he could read over my shoulder. 

 

I kept flipping pages and got part way through chapter 7, and stopped to look at the image at the beginning of section 2, which appeared to be a non-descript box of electronics with very few controls -- only a keylock between a couple of what appeared to be pushbuttons, with three indicator lamps or LEDs above those, on the right side of a front bevel swept back towards the top, with an exaggerated lip along the bottom edge. A large, black, blank faceplate covered an an inset open area to the right of the buttons, extending across maybe three quarters of the front panel.

"EXORciser?" Rick read the section title out loud, and hummed the signature opening phrase from Mike Oldfield's "Tubular Bells".

"For getting the demons out of our designs?" 

We both laughed. 

"Somebody at Motorola must have a sense of humor." He shook his head. "Looks kind of like a squashed toaster oven." 

"No blinking lights?" I turned the page. "Seventeen inches wide, nineteen deep, seven high. Forty-five pounds." I turned the page back.

"The Altair 8800 looks a lot more interesting, with the switches and lights on the front panel."

"I wonder if we could put that kind of front panel on this."  

"I wonder how much it costs, and what you can do with it."

 

 

Which we did when we arrived at the library. 

The librarian took us to the section where the microprocessor books were.

"These are reference works, so we can't let you check them out," she advised us, pointing out the sign of the shelves that said the same thing.

"Thanks." 

 

"Hmm, Intel 8080. IBM 360. Fairchild F8. What's that?" Rick picked up one of the Fairchild manuals and thumbed through it.

"Here we are, Motorola M6800." I picked up one of the Motorola manuals and started thumbing through it.

"Do you need anything more?" the librarian asked.

"Do you know if you'll be getting manuals for other processors?" Rick asked.

She gave Rick a thoughtful look, and said, "Let me check." 

While she went to check, Rick looked at the F8 manual, and I looked at the Motorola manual.

"Wow." Rick muttered. "The F8 looks even more primitive than the 1802." 

We thumbed through the manuals. 

"What have we here?" I muttered. "Source code and engineering diagrams for an example cash register controller."

Rick put the F8 manual down and started looking over my shoulder. "I might be able to make some sense of that," he said.

We continued to peruse the source code for a few minutes, and the librarian returned.

"The electronics technology staff has requisitioned manuals for the, uhm, Western Design Center 6502 and a couple of Texas Instruments microprocessors," she said.

"9900?" Rick asked.

"That's the one," she answered. "Both seem to be really new products."

"That's what we understand," I responded. 

"If you give me your names and phone numbers, we can let you know when we get them."

We did so, and thanked her.


 

 

 

"Oh." Rick put his car in reverse, checked his mirrors and over his shoulder and backed out of the parking space. "I guess that explains it." 

We headed for the college.

"Maybe," he added.

"You don't believe me? You could come to Seminary, you know."

Rick laughed. "Maybe I should. Just to keep an eye on you two."

 

 

The calculus class was on the second floor of Wilkerson Hall, and we passed my dad's office on the way. But Dad was in class, so we didn't see him. 

In the calculus class, Professor White held up a loaf of pumpernickel.

"How are we going to measure the volume of this loaf of brot?" 

Rick raised his hand. "Cut it in slices and measure each slice?"

"You've been reading the text. Good for you."

One of the girls whose name I don't remember suggested, "Or he saw the sliced loaf on your desk."

"Being observant is also good." Professor White lifted the tray of sliced pumpernickel. "Now, how do we measure each slice?"

"Slice up a slice?" I suggested.

"Excellent. Now, could you draw that on the chalkboard?"

 

Professor White explained sums of infinitesimals, inviting us to thing of real-world examples, waxing excited about the elegance of correct solutions, calling correct math sexy.

After class, I suggested, "Hey, I wonder if there's any docs on microprocessors in the library."

Rick looked thoughtful. He said, "We probably do have time to check."

At the library, I headed for the card catalog. Rick asked at the checkout counter. We both ended up in the stacks about the same time.

"Please note," the librarian who helped Rick said, "that this is a reference shelf, and these books cannot be checked out." 

"Got it," I answered, and Rick nodded. 

"Hmm, Intel 8080. IBM 360. Fairchild F8. What's that?" Rick picked up one of the Fairchild manuals and thumbed through it.

"Here we are, Motorola M6800." I picked up one of the Motorola manuals and started thumbing through it.

"Do you need anything more?" the librarian asked.

"Do you know if you'll be getting manuals for other processors?" Rick asked.

She gave Rick a thoughtful look, and said, "Let me check." 

While she went to check, Rick looked at the F8 manual, and I looked at the Motorola manual.

"Wow." Rick muttered. "The F8 looks even more primitive than the 1802." 

We thumbed through the manuals. 

"What have we here?" I muttered. "Source code and engineering diagrams for an example cash register controller."

Rick put the F8 manual down and started looking over my shoulder. "I might be able to make some sense of that," he said.

We continued to peruse the source code for a few minutes, and the librarian returned.

"The electronics technology staff has requisitioned manuals for the, uhm, Western Design Center 6502 and a couple of Texas Instruments microprocessors," she said.

"9900?" Rick asked.

"That's the one," she answered. "Both seem to be really new products."

"That's what we understand," I responded. 

"If you give me your names and phone numbers, we can let you know when we get them."

We did so, and thanked her.

"Are we going to eat lunch?" Rick asked as she returned to the checkout counter.

"I guess we can look at these some more tomorrow," I answered.

We left and got in his car and headed for the Whataburger down the road.

"Onions today?" Rick joked as we pulled into the drive-in.

I chuckled. "Is that relevant?" 

But I did order onions, lettuce, tomato, pickles, and cheese, with ketchup and mayonnaise. Rick ordered a grilled chicken lunch.

We talked about math and electronics while we ate, and then headed for Permian. 

As we pulled into the east student parking lot, Rick said, "Look who's here."

Sapphire was waiting outside the south-east wing entrance. I waved, and she waved back.

"What's up?" I asked, as we approached.

She shook her head. "Just missing you."

I could feel Rick's eyes roll, even though I didn't look to check.

"I'm kind of, I don't know. You're seminary was --"

Rick filled in, "Wild? Cult-like?"

"Hey," I complained.

"Wild, yes. Cult-like, no. Just things I never knew about Moses and Abraham." 

"Maybe I should come to your Seminary to protect Sapphire," Rick suggested.

"Ah, how sweet." She gave him a moue.

"Stop. I'm melting." Rick chuckled.

The electronics classroom/lab was the easternmost room of the south wing, so we talked outside until a few minutes before the bell, and Sapphire hurried for her class.

"You know you're welcome to visit the Seminary class any time."

"I need my beauty sleep."

 

------------------

******** July 23rd 

Public school started on 23rd August, a Monday.
 
OC started on 25th.
 
But we don't care. 
 
Newspaper collections were on the 5th, which was Sunday 
 
******* March 28th: 
 
Start lecture with mention that CPU has similar architecture, ALU and registers, and instruction sets and register sets are somewhat chosen to fit in possible number of transistors with current technology 
 

Sapphire asks Joe to throw away some trash at his house and hands him her purse, and he objects to having to look through himself, and they talk obliquely about feminine hygiene products wrapped in newspaper. 

 
Somewhere I want comment on forcing the same tools and the same tests as opposing unity because we are all different and the only unity we can ever have is helping each other solve individual problems. 
 
******
 

68 is illegal op code on 1802

Sapphire asks Joe to throw away some trash at his house and hands him her purse, and he objects to having to look through himself, and they talk obliquely about feminine hygiene products wrapped in newspaper. 


But Joe was actually named after Marion G. Romney 

 

The eagle flies with the dove, if you can't be with the one you love, honey, love the one you're with 

 

Chicago -- Just you and Me, Wishing You Were Here,  Call on Me, Make Me Smile, Feeling Stronger Every Day when they say goodbye in 33209, Searching for so Long when  Joe gets together with Julia or Chikako?

Gordon Lightfoot Beautiful and Joe Cocker (Billy Preston/Bruce Fisher) You Are So Beautiful 



Rick -- there is such a thing as gay, but it's an artifact of culture 
 

 


TOC
Next
Where it starts

Copyright 2025, 2026, Joel Matthew Rees






Monday, July 20, 2026

3809/2801: ALUs, Register Indirect Review, Role Playing the 6800

2801
ALUs, Register Indirect Review,
Role Playing the 6800

Motorola M6800 EXORcises
TOC

When we walked into the southeast wing from the entrance closest to the Permian student parking, Hec, Cyndy, and Sapphire were talking in the hall outside the electronics lab.

"There she is, Merry."

I glanced aside at Rick with a raised eyebrow before raising my left hand in a mock salute as we approached, saying, "Greetings, earthlings."

Hec cocked his head sideways, and Cyndy gave me an eye-roll.

Sapphire gave me a sour moue. "Hah. You only think you are of a superior race," she jested, before reaching out for my hand. I gave her hand a squeeze before we both dropped our hands a little guiltily.

Rick laughed. "Nope. Nothing to see here, folks." 

Sapphire gave him a look of mock innocent perplexity.

He just grinned. 

"How was calculus?" she asked.

"No class today, we just studied in the library," he answered. "Found some microprocessor manuals. They have the 1802 manual, too, Hec."

"You didn't check it out for me?"

"The manuals are all in the reference section," I explained.

"So you can't check any of them out," Cyndy said, somewhat wistfully.

"We could meet at the library, I think," Rick suggested. "Although the only time after school I'll be able to do that will be Friday or Saturday evening. Or Sunday."

"Do you guys have a game Saturday?" I asked. 

"Friday," Sapphire answered. "Which brings up a question. Will you and Rick be with us at the games?" 

Rick and I looked at each other. 

"I'm going to have to think about this," Rick said.

I nodded. "I think I'm game for it, but maybe not every game. You're not asking Hec. I guess he's committed?" 

"I'm like you, not every game," Hec replied. "But I'm a student here."

"Which raises another question," Rick pointed out. "Are there going to be riots on the field or in the schools if OHS guys are dancing with the Permian cheer dance team at game time?"

I grimaced. "You could have talked all day --"

"But somebody has to ask," Cyndy finished for me. 

We all stood in silence for a moment or two.

I spoke up. "I guess I was hoping Ms. Michaels would run that question past the school staff."

Sapphire said, "Well, yeah. Ms. Michaels wants to know what you and Rick are thinking before she starts a discussion."

Rick looked at me and I nodded. 

"So, not this Friday," I said. "I'm not sure we're going to be that much up to speed anyway." 

"In theory, if it won't cause riots," Rick said, "sometimes. But not when Permian and OHS are playing each other."

Sapphire nodded. "Probably best not then." 

"Sapphire, you need to get to class," Cyndy reminded her.

"That's true." She frowned. "We can talk about it later?"

Rick and I nodded.

Sapphire touched fingers with Cyndy and reached out to me. I met her hand with mine and we gave each other's hands another squeeze, and she left. The other four of us entered the classroom.

As we sat down, Hec asked, "What happened between you two last night?"

"Who?" I dodged.

"You and Sapphire," Cyndy said. 

"We just studied and talked," I replied.

Rick said, "Near as I can tell, Sapphire really likes our Merry."

Cyndy gave Rick a sharp look. 

Hec laughed and asked. "Who's the toughest guy in the movies you can think of, Cyndy?" 

"Hoss?"

I nodded and drawled, "The best fruit is not what falls, but what you have to reach for."

Cyndy gave me a worried look. 

Rick laughed. "Dan Blocker's a good answer, and something of a local, but not the one Hec was thinking of."

"Clint Eastwood?" 

I laughed. "Man's got to know his limitations."

Cyndy expression shifted to puzzlement. "I don't understand."

I said, "Lookin' back is a bad habit."

(For what it's worth, I probably would not have known any of these quotes. Well, maybe the Dan Blocker quote. I didn't have that much interest in movies. But you already know that Joe and I are not the same person.) 

She still looked puzzled. After a few moments of thought, she said, "John Wayne?"

Rick smirked. "Do you know what his real name is?"

She looked from Rick to Hec to me.  

"Rick heard about it from his mother," I explained, "and looked it up in the school library. Then he told everybody about it when I was getting teased about my first name at Sam Houston."

"So," she stalled while she thought. "John Wayne's real name is," she paused again, still looking puzzled. "Marion?"

Rick nodded. "Marion Robert Morrison."

Chuck volunteered from his table, "So Rick is the only person that gets to use Joe's first name."  

Chuck was also a Sam Houston alumni. 

(The name of that school, at least, has not changed. I understand that the school has been designated AVID now, however, and I'm not sure what to think of that.) 

I gave Chuck a thumbs-up and Cyndy a lopsided smile and added, "Not that I'm mean about it or anything. I just may not answer."

The bell rang, and Mr. Mori stood up. 

"Not," commented Chuck, "that any of that tells us about last night." 

I turned and gave him raised eyebrows, but he just grinned and shrugged. 

"Before we dig into the promised discussion of the 6502's indexing modes, there's something I'd like you all to consider," Mr. Mori announced.

He put a transparency on the overhead projector and turned it on.

"Nothing to tell," I replied to Chuck, who just kept grinning. 

"I'm kind of hoping this looks familiar from yesterday," Mr. Mori added.

We all thought about it for a few moments, and Cyndy suggested, "It looks kind of like the CPU and memory?"

"What is like the CPU and memory?"

Hec spoke up, "I think I get it, too. Kind of like in the same way the CPU interfaces with RAM, the ALU interfaces with registers."

"So what are we looking at?"

Rick said, "It's a partial diagram of the inside of a CPU." 

"You say that with confidence."

Rick glanced back at me and I gave him a thumbs-up. 

"Yeah."

"That's what I want everyone to see. Registers are like very fast RAM, inside the CPU chip. Usually. Except the 9900's working registers. And the ALU plays a central role. But I've left out the control signals and the control unit. Let's add some of those." He swapped transparencies.

 

"Any impressions of that that anyone wants to bring up?"

Bob said, "Well, something's got to tell the ALU and the registers what to do, so they call it a control unit?"

"Anything else?"

Bill said, "The control unit also controls the data paths between the registers and the ALU. That's the buffers?"

"Good. Now the ALU handles ordinary math, what handles the addresses?"

Karl said, "Why can't the ALU handle addresses?"

Ted said, "It can, but in some CPUs there's a separate address unit to speed things up."

"Good comments, both of you." 

Mr. Mori swapped transparencies again.


"Some CPUs do have a separate address unit. So, Joe, what do you think this diagram is missing?"

"Something needs to interface between the CPU and memory and I/O," I responded.

"What are those called?"

Bill replied for me. "Aren't those the data and address buffers?" 

"Good." 

Scott said, "And it's also missing the instruction pointer."

"Why is that important, Scott?"

"The diagram doesn't show how we know what the current instruction is, or how we get immediate data from instructions into either the ALU or the address unit."

"Great."

(Dang, these guys are sharp. I wish I'd know them when I was in high school in your reality.) 

"I don't want to design a CPU in class with everyone today, so I'm not going to add those to this diagram. Today. Anyway, I hope you'll be able to visualize what's going on in the CPU a little better with these."

"One more thing I want to do before we move on to the 6502 is review what we've seen of register indirect mode and indexing. Who remembers from yesterday what register indirect mode is?" 

No response.

"Still shifting gears?" 

Pete raised a hesitant hand. 

"Pete?" 

"In register indirect, a CPU register points to the memory location for the instruction's operand." 

"Thank you, Mr. Higgs." Mr. Mori put a transparency from the previous lesson back up. 

  

"We looked at the 9900 pointing to its workspace in RAM with the W register, and then we looked at its ability to point to general locations using any 16-bit register. Almost any. And the working registers are actually already in memory, not in the CPU."

Frank spoke up. "Why doesn't the 9900 have the registers cached internally?" 

Mr. Mori gave him a knowing smirk. "Greedy, aren't we?"

"Is microprocessor technology so far behind?" 

"Every semiconductor manufacturer building microprocessors is pushing the edges of their manufacturing technology. When they design a CPU, they have to make a bet on how many transistors they can squeeze into one chip without running into power problems or reactance and crossfeed issues or even just plain dust problems."

"It doesn't seem like it should be that hard."

"Maybe when you get through college you can get a job with TI and show them how."

Frank laughed. "Okay, okay. Maybe I am too impatient. Maybe they still won't have that solved by the time I finish college."

Bob asked, "Cache?"

I said, "Cache is fast memory, where you put the data you need quickly."

"Isn't that what internal registers are anyway?"

Mr. Mori said, "We will need to actually discuss this in detail, but, with most CPUs, you have to explicitly bring data into the registers, and if you need what was there before, you have to save it first. The 9900 avoids the saving and restoring steps by keeping the registers in memory anyway and just moving pointers, but that makes the working registers slower than internal registers. I think what Frank wants is for the CPU to keep the registers internal, but still manage the saving and restoring automatically, so that the registers can be fast and the programmer doesn't have to think about it. That's called 'cache'."

"Yeah. That's what I'm thinking," Frank nodded.

"It's an interesting goal."

"I'll keep that in mind."

(In the reality you know, TI's next major microprocessor design, the TMS320 digital signal processor, had a full set of internal registers, but without any automatic caching -- no automatic saving and restoring. And TI never tried caching the registers on any publicly available 9900 variant, although it did provide some limited faster internal memory to allocate the registers within on some 99XX series microcontrollers -- which gets a bit more than halfway there for those microcontrollers. 

Limited forms of automatic caching for working set registers were used in some reduced instruction set processor designs from other companies, but never really caught on. It was generally considered more effective use of both semiconductor area and instruction architecture design to put the burden of saving and restoring registers on the software, letting high-level language compilers do the hard work. Other types of caching did catch on and are heavily used in modern CPUs. And this is distracting us from the story.) 

Mr. Mori nodded. "Back to the register indirect addressing, does the 8080 have such a thing?"

Barry responded, reading from his notes. "H and L can be used as a pair to point to memory."

Scott added, "B:C and D:E can also point to memory for some instructions."

Mr. Mori blinked. "Scott, you've been reading your dad's manuals at home."

Scott grinned.

Mr. Mori chuckled. "Barry and Scott are both correct, and we'll look at the specifics later.

"What's the difference?" Karl asked. 

Scott replied, "I'm not positive, but I think the only instructions I saw that use B:C and D:E for pointing to memory are data moves."

"And we will look at those closer later on, but that's what I understand." Mr. Mori nodded. "How about the 1802?"

Hec and Cyndy both started to reply at the same time,

"Pretty much, ..."

"You said, ..." 

And then they stopped speaking, looking at each other and laughing.

"You first," Hec said.

Cyndy gave him a lopsided smile. "Okay. She turned to Mr. Mori. "You said yesterday, pretty much any of the sixteen registers can point to memory." 

Mr. Mori continued nodding. "What about the 6800?"

Rick and I looked at each other.

Bill spoke up. "X is used as an index register with zero offset for register indirect."

Rick and I both turned and gave Bill a thumbs-up.

"Great." Mr. Mori nodded. "I think we're all paying attention. What does anyone remember about the 6502 from yesterday?"

Harvey raised his hand, "X and Y are only 8 bits wide."

"Excellent. What does that imply about X and Y being used as index registers?"

Harvey hesitated, then said, "Does that mean they can only point directly into page zero?" 

Mark grumbled, "Just about have to."

Pete said, "What if the 6502 allows a 16-bit constant base?"

Mr. Mori turned to him and said, "You're getting ahead of me."

"Sorry."

"Not a problem." Mr. Mori grinned. "In fact, that's one of the things we promised to talk about today. We'll get there shortly. So," he paused. "How many of you remember the indexing mode of the 9900 from yesterday, how it differs from the register indirect mode?"  

Frank read from his notes, "The constant in the instruction plus index register contents is the operand address. If the constant is the base address of an array, the register can index the array, and --"

Mr. Mori interrupted him. "Good. Meaning?"He swapped the transparency on the overhead projector.

"We know where the array is, and the register is used to pick the element of the array that we want. The address of the element we're accessing is the constant base address plus the offset into the array."

"Are we all okay for that?"

There were no complaints.

"Pete, since Frank told us one way to interpret this, you tell us the other."   Again he swapped transparencies.

Pete hesitated, then said, "Sometimes you have a lot of arrays that have the same form, and you want to access the same part of each. So the constant part is going to be offset that doesn't change, and the index register will point to the address of the base of the array that you want to look at. The sum still points to the byte you want to access."

"Excellent, again." 

"But if we are talking about strings like that," Pete continued, "before we look at the third letter, we're going to want to check the length byte at offset zero to be sure there is a third letter."

Professor Mori beamed. "Very excellent. I'm going to give everyone who didn't quite follow that a half a minute to think about it."

Bob asked, "How do we check that?"

I volunteered, "Each processor has an instruction to compare a byte with a known value, so you would probably load the count and compare it to the length you want to check."

"Then what?" Mr. Mori asked.

Hec answered, "If it's too small, jump out to do something else."

"Good. And we'll talk more about that later. Now, Joe, what happens when you don't know in advance either which array you're going to be accessing or which element?"

"You mean, neither is constant?" I asked.

"Right." 

"Is there an addressing mode for the 9900 that adds two registers to get the operand address?" I asked.

"Well, actually, no."

(It would be about a year and a half in your reality before Motorola officially announced the 6809, which included such modes by combining the address in an index register with on offset in an accumulator. And about a half a year later, as the 6809 was beginning to ship samples, Motorola would formally announce another new processor, the 68000, which also included such a mode, being able to form an effective address by temporarily adding either a data register or an address register to an address register. And several years after that, Motorola would announce the 68020 with addressing modes that were just way too rich for most programmers to keep in their heads. 

Intel would announce the 8086 about the same time Motorola announced the 6809, and the 8086 would include what they called based-indexed mode which combined two indexable registers in this way. It would also include something that kind of looked like this but wasn't, and wasn't intended as such, which they called segmented addressing. I objected to their     use of the term "segmented" when I studied the 8086 sometime later. But that's all in your timeline. On the other hand, ... but I'm getting way off-topic and way ahead of myself again.)

Cyndy spoke before I could. "Then you just use one instruction to add the address and the offset in registers and use the sum in the register in a register indirect mode instruction. It'll require two instructions and leave the target address in a register."

"Hey. That's what I was going to say." I complained, jokingly.

She turned around and lifted her hand with a grin, and we slapped palms.

Mr. Mori nodded with a wry smile, and said, "How many of you didn't follow that?"

Nobody raised a hand.

"I don't believe you all understood it, so I'll ask how many did follow it and are willing to try to explain it at the whiteboard?"

Several of us raised our hands. 

"Ted?" Mr. Mori held up a marker.

Ted stood up and took the marker and, referring back to the transparency, drew the following on the whiteboard while he explained: 

"The address of the array is in the register we're calling Rb. That's any of the sixteen registers."

Mr. Mori nodded. "Well, there are some registers you might not want to use, but, yeah. So, for now we can assume more-or-less any but R0. Do you have a manual at home?"

"Yeah."

"Cool. I might want you to bring it to class sometimes, if it's okay with your dad."

"I think I could. Dad didn't say anything about a non-disclosure agreement."

"Great." 

"The array is a string in this example, a character string, right?" Ted paused. "But I decided the offset is going to be a four this time." 

Mr. Mori interrupted. "Why is that?"

"Just to emphasize that it's in a register and not a constant in the instruction stream."

"Thank you for thinking of that."

Ted continued, "And I'm calling the register that the offset is in Rx, because we don't need to know which it's going to be in -- saying X for index. So we use an add instruction to add the offset to the base, and the sum ends up in Rb." 

He stopped and thought. "Maybe I didn't want to do that."

"Maybe not, but we'll go with that for now. The point is that the CPU has executed one instruction, and the value of one or the other register has been altered, right?"

"Right. After the add instruction, the result in Rb is N plus four, so it's pointing to the letter 'i'." 

"Very good."

"But, as I said, I realized while I was explaining it that now Rb is no longer pointing to the beginning of the name, and that may not be what I wanted. It would also work to add Rb to Rx, instead, wouldn't it?"

"Why would you want to do that?"

"To leave Rb pointing to the base of the array for later math, and maybe to allow bumping Rx up and down from where the index is left pointing, to address another nearby byte." 

"Yeah, that would work, if I understand what I've read about the 9900 correctly. And, while you can always point back by subtracting four, I think your instinct to leave Rb pointing to the base is good. It would be less confusing to leave the base address in Rb, as you say. Very astute."

Cyndy raised her hand. "So we could do the constant offset or constant base this way, too?"

 Mr. Mori pursed his lips and furrowed his brow. "Yes, if you load the constant into register Rx, you can add them explicitly, and have the effective address in a register. And we probably want to talk more about this when we talk about other CPUs in more detail. But constant plus index happens a lot, so the indexed mode makes a useful quick shortcut. But, yes, we could do it all in registers with extra instructions if we need to."

She nodded. 

Hec said, "But won't that take more time, since you have to fetch instructions and do explicit math that the address unit could be doing in parallel?"  He looked at Cyndy. "Uhm, although it does leave you with the target address in a register, if you need to use it again."

Cyndy gave him a tight smile and a slow blink.

"Sorry," he said.

"No problem."

Karl piped up. "Somebody's in trouble tonight."

Cyndy turned to him and blinked again. "Whatever do you mean?"

Mr. Mori said, not quite suppressing a smile, "I do appreciate it when you settle your differences outside of class, guys." 

Most of the other boys laughed. Rick and I suppressed our grins. Cyndy smiled knowingly at no one in particular.

Hec reached a raised, hesitant palm to Cyndy, and she touched palms with him, lightly. 

Mr. Mori said, "Cyndy and Hec are pointing out something important here, and it's why I wanted to show you that some CPUs have a somewhat independent address unit. File that away in your brains and we'll come back to it."

He gave us a moment to think.

"Okay, Scott, can you tell us how to do any of this kind of indexing on the 8080?"

Scott shook his head. Then, after a moment's thought, he said, "Wait, maybe put the base address in D:E so we can keep the base, and the offset in H:L, and add, D:E to H:L?"

Mr. Mori nodded. "You think your dad would let you bring his manual to class?"

"He usually keeps it in his office, but I could ask."

"That might be nice. I think you're right. As far as I know, there's no constant offset plus index addressing mode on the 8080, so, whether we have constant offsets or variable offsets, we have to explicitly add them in registers to get the target addresses." He paused.

"I've heard that some engineers have left Intel and formed a company called Zilog that has announced an 8080-compatible processor, called the Z-80, that does have indexed mode addressing, but I haven't seen a lot of information on it yet."

Bill volunteered, "Kind of like the engineers who left Motorola to make the 6502?" 

"Well, Chuck Peddle and his group didn't have as much financial backing when they left Motorola, so, instead of forming their own company, they took their ideas to MOS Technology -- which was a company that already existed. Similar but different."

He waited for us to shift gears before continuing. "But the 8080 does have instructions to help with this. Can you tell us what they are, Scott?"

"I can't keep them in my head."

"I can't either. So far I'm just working from code snippets I've found in magazine articles. I'm not sure I should show you this diagram, because it might be wrong, but let's see what I think the constant base case might look like."

Mr. Mori swapped the transparency on the projector out.


"You can see that it takes one instruction, L-X-I, to load the constant base and another, D-A-D, to add the base to the offset to get what we want. And this is what Cyndy was talking about when she asked about adding the base and offset in registers. The Z-80 may have an address mode or operator that does it for us, but the 8080 does not and we have to do it by hand the way Cyndy says." 

Again, he waited for us to think about things. "Scott, do you think you can show us the constant offset case from this?"

"Oh, sure." Scott stood and went up to the whiteboard, borrowing the marker from Mr. Mori.

"Hardly anything to change," he said and started copying from the transparency. "The DAD for the addition can be the same. But the constant we are going to load will be the offset, not the base, and we will probably load it into H:L to leave the base address alone." He continued working on the diagram in silence for a short bit, and then announced, "That should do it."

"Load the constant offset into H:L, leave the base address in D:E alone, and that's that."

"Thanks. Now, Barry, can you modify this for the general case, with variable base in D:E and variable constant in H:L?"

Scott turned towards Barry and raised the marker and eraser in his hands.

Barry stood and took the marker and eraser from Scott and went to the board. He studied the diagram for a moment, erased one instruction and moved those after it up. 

"Yep. I think that's it. Wait, I should edit the offset to match the 9900 example. And fix some comments."

  

"Looks pretty cool, doesn't it?" Mr. Mori said. But I should warn you all, things get a little messy when the base and offset aren't already in the right registers. Thank you Barry."

Barry put the marker and eraser on the white board tray and sat down. 

Mr. Mori frowned, and then asked, "Can anyone talk about how this works on the 1802?"

None of us volunteered.

"Bob? Chuck? Mark? Bill?" 

They all shook their heads, so he turned toward our table. "Hec?"

"Ask me next week."

"Hey, what?"

"Rick and Joe were saying the OC library has 1802 docs, so we're planning on going to take a look at them this weekend." 

"Oh. Cool. Maybe I can get them to let me take a look at them, too."

Chuck said, "If you need somebody to get you in, I could meet you there."

Mr. Mori blinked. "That would be great. Let's talk about that after class." 

"Just a guess," I offered. "On the 1802 are we going to have to do the address math a byte at a time, and then use the X register to switch the register that has the result address to the current index?"

"That's a good guess, from what I understand. Any body not get an idea what that looks like?" 

Mark said, "I think we're all pretty vague on it."

"Let's wait to draw pictures until I can get a look at an actual manual. For now, let's ask Joe and Rick how this is going to look on the 6800." 

"You never drew us any pictures of this yesterday," Rick complained as he turned to me.

"Give it a shot, Stant," I said 

"Can I be lazy and just point out that it looks more or less like the 9900 for the, uhm," he looked at his notes, "constant offset in a string case," he looked at me and then Chuck for confirmation.

We both nodded.

"And if the array is in the first 256 bytes of memory, you can use the constant base plus register index form for that, too," he checked with me again.

I nodded.

"And then I can just draw the one Joe just did at the library where both the array base and the offset are not known until the program starts running?" He looked at Mr. Mori.

Mr. Mori pursed his lips, nodding. "Why that one only?"

"Because it's going to take more instructions to do the addition," Rick trailed off. Then he said, "Maybe we should just draw them all."

Mr. Mori grinned. "I'll leave that up to you guys."

"You do the constant base, Joe."

"Sure, give me that one. How about you grab the data sheet?" I picked up my notes from the library and went to the board and started erasing. Rick went to the pile of documents at the front of the room and found the 6800 data sheet.

We looked through the data sheet and at my notes.

Rick said, "Can we see the one from the 9900 again?"

"Sure." Mr. Mori put the transparency on the projector.

Rick pointed at he instruction list from the 9900 example projected on the white board, and I nodded and sketched the constant base case out to one side of the projection on the board. 


"The main difference between the 9900 and the 6800 here is that the array has to start in the first 256 bytes of the address space," I explained. 

I stopped and thought a minute. "And I guess I want to point out that, where on the 8080 diagrams, we were calling the instruction of interest op code C, that was after the address calculation , on the 9900 example and in this diagram, the instruction of interest is op-code B, and op-code C is already the next instruction. Everything happens in one instruction."

Mr. Mori nodded. "You say the array has to start in the first 256 bytes. How about the test score? Does the array have to all fit within the first 256 bytes of memory?"

I scratched my head while I thought. "If we are doing something other than bumping the pointer in X up and down a little, the address math might get complicated, but X is 16 bits wide, so I'd guess not." 

"I think that's correct." 

"Your turn, Rick." I handed the marker and eraser to him. 

Instead of immediately modifying my diagram, Rick first pointed to the short op-code list.

"Just to recap about the instructions, 6800 instructions are variable length, aren't they Joe?" Rick asked.

"Yeah," I replied.

"So the byte at 1017 is the last byte of instruction op code A."

"Yep."

"Op code B at 1018 is the indexed mode op-code byte, and the constant that follows it at 1019 is the base address, which is limited to between 0 and 256."

"Right."

"And the next op-code, op-code C, starts at 1020."

"Mmm hmm." 

"Got it." Rick started modifying the diagram. "Now, this time, the base address is going to be in X, and it's going to be a full 16-bit address. And we're probably going to want to test the length byte at offset zero first, but we haven't been showing that, so we won't do that in this diagram."

"Fair enough," Mr. Mori commented.

"Pretty much the same as the 9900, again." 

"And this works as long as the array is smaller than 256 bytes."

"Right." 

"I assume that it's the address unit that generates the address from the index register and the constant in the instruction," Rick added. 

"Very good," Mr. Mori said. 

Rick looked at me and held up the marker.

I grinned.

He said, "You were the one writing something like this in the library."

"Dang, but I'm a pushover," I complained as I took the marker and eraser and turned to the board and looked at the diagram, trying to plan out where to add all the extra instructions. 

"In the library," I thought out loud, "we worked out some steps to add B to X. But that only works for 256-byte offsets."

"Do you have that?" Mr. Mori asked.

Rick picked up my notes and waved them.

Mr. Mori said, "Let's take a look at it." 

"What did we call the place in memory to work on the index?" I asked.

"You called it X16." Rick showed me the page.

"Okay" I erased everything but the string. "We can put X16 in the direct page to save cycles and op-code bytes, because the direct page mode only needs one byte of address." I drew the bytes for X16 on the board where I thought they would be out of the way. "To do that, X16 has to be at an address below 255."

"Below 255, but not at 255?" Mr. Mori asked.

"X16 takes two bytes, and we need both bytes to be addressable in direct page mode."

"Good." 

"At the start of the code, X will be pointing to the beginning of the name. B will have the offset, and we'll assume that's 4, like Ted did." I drew in register X before and after, and drew B with a 4 in it, and looked around at Ted, who gave me a thumbs-up.

Then I looked back at the notes Rick was holding for me. "And after we add the offset, X will point to the 'i', of course. And it's going to be easier to show you the actual instructions than wave my hands at them."

I diagrammed a piece of memory starting at 1017. "Last byte of the preceding op-code."

I filled in the direct page store X instruction, using the mnemonic.

"Okay, Rick, what was next?"

"ADD accumulator B to the low byte of X16."

"Since the 6800 is most significant byte first, the low byte is at X16 plus one."

I paused to examine the diagram on the board.

"Next thing you did was load accumulator A from the high byte."

"The load instruction on the 6800 doesn't affect the carry flag. Does the store?" I asked.

Rick picked the data sheet back up and scanned it. "Nope."

"I think we could store B first and then we wouldn't have to use A."

"You might be right. Wish we had some way to check."

"Me, too." I wrote in the store instruction. 

"Me three," echoed Mr. Mori. 

A number of us chuckled.

"So we load the high byte at X16 into B." I wrote that into the diagram. "And, Rick, you were the one that pointed out we could just use the add carry instruction in the immediate mode to add zero to B, and get the carry added in." I added that to the diagram.

Mr. Mori said, "Wait, slow down and say that again."

Rick explained. "We want to add the carry to the high byte. But we don't have anything else to add besides the carry. There's no single special instruction that we know of to just add the carry in without adding something else."

 "I see."

"Adding a constant zero wouldn't usually make a lot of sense, but if it's the add with carry instruction, it does the trick." 

"Very good." 

"And Rick was the one who figured that out," I said. "Then we store the updated high byte from B in," I ran out of space at the bottom of the whiteboard and moved over to continue writing op-codes. "And load the result into X and we're finally pointing to the byte we want." 

"That's a lot of work," Karl complained.

"That's what Rick and I were thinking. But we didn't find any instruction to directly add an accumulator to X or to add sixteen bits at once."  

Mr. Mori said, "Now, X16 really could be anywhere in memory, right?"

"True, but then you'd use the longer absolute mode that Motorola calls extended mode, which would take extra cycles and and extra byte of address for each operation on X16."

"How many extra op-code bytes would that be?" Mr. Mori asked.

"Every direct page mode instruction would become an extended mode instruction, and that would take an extra byte for each one. There are," I counted, "six DP mode instructions, so that would be six extra bytes. I think it's one extra cycle per instruction, too. Is that right, Rick?"

Rick looked at the CPU datasheet and nodded. "Yep. Not as much speedup as I had thought."

"Yeah," I agreed. 

(Spoiler: Motorola would announce a single-chip micro-controller CPU called the 6801 sometime during the next year in your timeline, which would be an extension of the 6800 that had both the add B to X instruction, ABX, and 16-bit math operators that paired the A and B accumulators as a single double accumulator, D -- along with a few other key new features. But no SBX to subtract B from X. It would not have all the capabilities of the 6809, but it would be a significant improvement.)

"Joe decided not to show the individual steps to add the two bytes in the diagram. Is that confusing to anyone?"

Several of the guys raised their hands.

"Okay, Joe, do you mind if I take over for a bit?"

"Sure. I mean, no I don't mind. Please take over."

There were scattered chuckles. 

"Okay, we're going to role play the computer." Mr. Mori grinned and paused for effect before continuing. "When I call you, stand up. Joe, you and Rick remain standing. Joe is going to read the instructions, and Rick is going to tell us what happens to each byte."

"Why does Joe get the easy job?" Rick complained with a grin.

More chuckles. 

Mr. Mori laughed, too. 

"Scott, you're direct page memory location X16."

Scott stood up. "What do I do?"

"Mostly remember your current value and tell us what it is."

"I guess I can do that." 

"But we need an actual, concrete example address. Rick, what's the actual address?"

"I don't know. Ten, maybe?"

"Ten it is. Scott, you're at location ten. Barry, you're at location X16 plus one. What's your address?"

"Uh, eleven?"

"Okay, Bob, you're accumulator B. What do you have when the code starts here?"

"Four."

"Right. Karl, you're the index register, X. What have you got when the code starts?" 

"N."

"We need a concrete value for N so Barry and Scott know what hits them." 

Karl looked at Rick.

"You pick," Rick said. 

"Anything less than 65,536?" Karl asked.

"What do you say, Joe?" Mr. Mori asked.

"I have the impression that addresses above 32,767 get used for stuff, so maybe we'd prefer below that."

"How about 31,999?"

I shrugged "I think it would be okay, but we have to divide that into high and low bytes."

Karl looked over at Barry with a grin. "You do the math."

"Well, 32,000 divided by 256," He looked at Mr. Mori, who nodded. He continued, "Is a hundred twenty-five, so the high byte is 124."

Scott nodded. "And the low byte is 255."

"Okay. But you don't have those yet," Mr. Mori explained. "What do you have?"

Barry said, "Something random?"

"Probably."

"Okay, I have seventeen."

Scott said, "I'll have a hundred seventeen." 

"Sounds random," Mr. Mori confirmed. "Now we need someone to be the carry flag. Mark?" 

"Okay. I'm random to start, too?"

"Yeah."

"Then I'll say there'll be no carry to start." 

"Okay, Joe, read the instructions."

"Store X at location ten."

Karl said, "Scott first?"

Rick said, "Yeah. Scott gets the most significant byte."

Karl said, "Scott gets one twenty-four." 

Scott said, "124."

Rick continued, "And Barry gets the least significant byte." 

"Barry gets two fifty-five," Karl said.

Barry said, "255."

I said, "Now, add B from location eleven."

Rick said, "We need the value in location eleven to store in a temporary buffer?"

Mr. Mori nodded. 

Barry said, "255."

Rick said,  "Four and two fifty five makes --" he stopped. "The buffer can't hold anything bigger than 255, so it wraps around to three, with a carry."

Bob said, "Three." 

Mark said, "Carry." 

I continued, "Store B to location eleven." 

Rick said, "What Joe said." 

Bob said, "Three."

Barry said, "Three."

Mark said, "Carry unaffected?"

I said, "Right. Now load B from location ten."

Rick said, "Ditto." 

Scott said, "One twenty-four."

Bob said, "One twenty-four."

Mark said, "Carry unaffected, still?"

I said, "Right. Add constant zero to B with carry."

Rick said, "Constant zero read from the next byte of instruction and stored in buffer." 

Mark said, "We still have carry."

Rick said, "Adding the buffer and the carry to B results in one twenty-five." 

Bob said, "One twenty-five."

Mark said, "Now no carry."

I said, "Store B in location ten."

Rick said, "The data just moves." 

Bob said, "One twenty-five."

Scott said, "One twenty-five."

Mark said, "Carry unaffected, no carry."

I said, "Load X from location ten."

Rick said, "High byte from location ten." 

Scott said, "124."

Karl said, "I have to hold that 124 in half of me?"

Mr. Mori nodded. "Or maybe there is an intermediate buffer. One or the other."

Rick said, "Low byte from location eleven." 

Barry said, "3."

Karl said, "Man this gets boring." 

Mr. Mori grinned and said, "It's a good thing CPUs don't get bored, isn't it?"

We all laughed.

Karl grinned. "Well, anyway, with three in my low half and 124 in my high half, X is now 32,003. Does this get recalculated or just marked valid?"

Mr. Mori said, "At the end of the instruction clock cycle, it's assumed to be valid."

"Just assumed?" Karl checked.

"Just assumed. If there are no errors in the electronics, it has to be valid."

"Okay." 

I said, "And we are finally ready to do whatever op-code C was. But the instruction will be in indexed mode, and the index byte will be zero."

"Yay," Karl said, and we all laughed.

Mr. Mori commented, "I don't see a return instruction."

"Is that what makes code reusable?" Rick asked.

"If your code is constructed correctly," Mr. Mori replied.

"We haven't got that far yet," I apologized.

"That's okay. We'll get there. But this prepares us to talk about the 6502."

Rick asked, "Can we all sit down, then?"

"Sure." 

We all laughed and those of us standing sat down.

"Wait. Joe, Rick, I still need your help."

"What?" Rick started.

I said, "Oh. What if we have more than eight bits to add to X, right?"

"Right."

Rick and I stood up to look at the whiteboard, and Rick said, "If we start with the sixteen bits to add in A and B as a pair, we're already almost there with this."

I blinked, and said, "I think you're right."

"Combine two instructions into one," Rick went to the whiteboard and started writing the instruction sequence in a clear space.

101? opa (whatever it was)
1018 STX X16 (2 bytes)
1020 ADDB X16+1 (2 bytes)
1022 STAB X16+1 (2 bytes)
1024 ADCA X16 (2 bytes -- instead of LDAA X16; ADCA #0)
1026 STAA X16 (2 bytes)
1028 LDX X16 (2 bytes)
1030 opc 0,X (2 bytes)
1032 opd (whatever)

"The add with carry to A from X16 replaces the load B from X16 and add with carry immediate zero in the 8-bit version."

"What do you think, Joe?" Mr. Mori asked.

"I think it should work." 

"I do, too." 

"Could we put a return on the end of that as op-code D?" Rick asked.

"Depends on what op-code A is, perhaps," Mr. Mori replied. "But I don't see a likely problem with that. Anybody see a problem with that?"

Nobody said they saw a problem with it.  

"Okay, let's take a break." 

The bell rang. 

Cyndy stood and said, "Come on, Joe. We need to talk."

Hec and Rick looked up.

Cyndy shook her head. "Just Joe."

Rick said, casually, "Their alibi is that Maralea or Becca invited her to their, what was that, Joe, seminary? this morning." 

Cyndy looked questioningly at me. 

I explained, "That's what they told me. I was quite surprised to see her there. Pleasantly. Not complaining at all. And she seemed to enjoy the class."

"She's too ...," Cyndy reached for words.

Hec suggested, "Mellow?"

Cyndy gave him an accusing look.

"I think so, too," he added. 

Cyndy looked around. Some of the guys nearby were too studiously not listening. 

"Joe?"

"Well, ...," I stood up without completing the thought. 

Hec said, "Rick?" and stood up.

Rick nodded and stood, and Cyndy didn't object again, and the four of us headed outside to the parking lot.

"So what happened last night?" Cyndy asked again, when we were sure no one was close enough to hear.

"She didn't say?"

"She said it was kind of complicated, and just smiled." 

"Complicated. Kind of. But, really, I'd rather let her --"

"What's complicated?" Cyndy was getting excited.

"Well, her parents know my parents. My dad taught them Spanish at OC a long time ago."

"Oh."

"Yeah, they came over last night for a visit. Her mom was worried about me being a Mormon and all, but once they knew for sure who my dad was, they weren't worried any more."

Hec said, "It's not a bad reason to be mellow if she likes him."

Rick looked at me and grinned at me. "How much more aren't you telling me?" He chuckled and shook his head. "Never mind." 

Cyndy set her mouth in hesitant defiance. "So, did you kiss?"

"That's not a fair question," I replied. "You wouldn't want me to kiss and tell, would you? Or, to not kiss and tell?"

Cyndy's expression became unreadable. "But she's my friend." 

I thought for a moment, consulting my conscience about what was fair to share. 

"Her mom said no kissing, and we both decided it was a good idea. Not to, I mean."

Immediately, I regretted having said that much, even though I knew I was with friends. 

Hec said, "Come on, Cyn, trust your best friend." 

"It's not natural," she complained.

Rick said, "Not natural to not be kissing?"

I chuckled, and said, "I don't think that's what Cyndy meant."

Rick said, "I'm sure it's not what she thought she meant." 

"It's not. I mean --" Cyndy bit her lip.

Hec said, "Rick that wasn't fair. Cyndy's struggling about something here." 

Rick scratched the back of his neck. "Sorry. That wasn't called for."

I said, "Listen, you guys are friends. I just said more than I think I should have, even though I trust you guys to keep this between us. I think Sapphire and I agreed last night that we like each other too much to start kissing too soon. Can we leave it at that?" 

Cyndy closed her eyes and said nothing for a few breaths. Then she reached out to Hec, and Hec gave her a hug. And she touched finger tips with Rick and then with me.

"Thanks," she said.

Rick said, "Let's get back to class."

Cyndy nodded, and she and Hec turned back to the school.

Rick held back and sub-vocalized, "I'm holding you to that. Both of you."

I nodded once, and we headed in. 

TOC
6502 Indexed Addressing,
Including Memory Indirect
Where it starts

Copyright 2026 Joel Matthew Rees




[Most recent edit record here:  https://joelrees-novels.blogspot.com/2026/07/mark01-3809-2801-alus-register-indirect-role-playing-6800.html]


3809/2801: Practice Makes Practice

2801 Practice Makes Practice 6502 Indexed Addressing,  Including Memory Indirect ...