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
| 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."
| TOC | Next | |
| Where it starts |
Copyright 2025, 2026, Joel Matthew Rees
No comments:
Post a Comment