The Novels

Economics 101, a Novel (Rough Draft) -- My first sustained attempt at a novel, two-thirds finished in rough draft, and heading a little too far south.
What would you do if you and your study partner, with whom you had been seriously discussing marriage, suddenly found yourselves all alone together on a desert island? Study economics?
Sociology 500, a Romance (Second Draft) -- The first book in the Economics 101 Trilogy.(On hold.)
Karel and Dan, former American football teammates and now graduate students, meet fellow graduate students Kristie and Bobbie, and the four form a steady study group.

Featured Post

Sociology 500, a Romance, ch 1 pt 1 -- Introducing Bobbie

TOC Well, let's meet Roberta Whitmer. Bobbie entered the anthropology department office and looked around. Near the receptionis...

Sunday, February 16, 2020

Backup01: 33209: Bootstrapping, or Baby Steps

Backup of https://joelrees-novels.blogspot.com/2020/02/33209-bootstrapping-or-baby-steps.html. Major changes from Friday evening, completed 202002162126.
First backup at https://joel-rees-economics.blogspot.com/2020/02/bk-33209-bootstrapping-or-baby-steps.html.

Chapter 7.5: A little about the 6800 (and Others)

Chapter 8: Bootstrapping, or Baby Steps


After delivering the Saturday morning edition, I lined the inside of the box with sheet metal and installed the fan and the power supply, mounted the mainboard horizontally on offsets, grounded the board to the Faraday cage made by the sheet metal, mounted the keyboard, and tested that it still worked when everything was assembled.

Then, while I worked on designing the dynamic RAM circuitry and the ROM circuitry, Giselle played with the computer, using Tiny BASIC and asking me how to do things as she experimented.

Departing drastically from the example refresh circuit in the Micro Chroma 68's manual, I decided to borrow the video display generator's scan for the refresh strobe.

You may be thinking that the video scan works on the wrong part of the address for refresh. You're right. Dynamic RAM refresh strobes have to count through the row addresses several hundred times per second. The VDG's lower address lines continuously count, completing their count tens of times per second, but if you attach the address lines in the usual way, the lines that count end up being column addresses, not row addresses.

However, contrary to ROM, RAM doesn't really care about the order it is addressed in. Where you write the data is where it reads back from, and if the address lines don't change between write and read, the readback succeeds without any notice that the lines don't match the labels.

Well, many dynamic RAMs have row burst mode for speed, and if you use row burst access, the row must be an actual row. Otherwise, you'd be burst accessing with gaps, which is generally not useful. Row burst wouldn't allow what I did at all. But the Micro Chroma 68 would definitely not need row burst mode. Adding cache RAM and seeing how far beyond 2 Megahertz I could overclock it was not part of the plan.

So, if I swapped the usual rank of row and column, I could borrow the low order address scan count for refresh strobe, by addressing the dRAM rows instead of the columns with the VDG low address lines. Doing this, the row refresh would be completed within the required timing of once every ten or so milliseconds.

I was a little worried that changing VDG modes would cause problems, but it looked like it would still be quick enough, even if the VDG skipped a frame. So I decided to wire it up and see if it would work.

I added a whole 6821 PIA for an extra bit of output to switch between the lower 32K and the upper 32K. That was a waste, but I thought I could use the extra bits elsewhere.

With a bit of additional logic, I was able to decode the selected 32K bank starting just above static RAM, at addresses $2000 to $9FFF, giving 40K of contiguous addressable RAM.

I quickly had enough of a circuit design put together to walk to Radio Shack and pick up perfboards, a bunch of headers and sockets for them, some 74LS series bus buffer latches, and some other parts, and start wiring the circuit up on one of the perfboards, using point-to-point soldering on the low-profile socket pins. I wasn't able to finish wiring the board before bedtime.

*****

On Sunday, Br. Burns gave me the name and contact information of the manager at the local IBM office, Margaret Bight, and told me she would be expecting to hear from me. I invited him to come take a look at the Micro Chroma 68, and he brought his family over to visit after church meetings.

"Not sure what to say. It looks like a very capable toy. Games, maybe?" was his impression.

Hard to argue with.

I spent Sunday evening at a young adult home evening activity, where we had a gospel-oriented discussion and played Uno after.

*****

Monday evening, I finished wiring up the dynamic RAM and wrote some code for testing it. It worked for both banks of 32 kilobytes, keeping memory contents even when switching between VDG modes.

However, when I tried using one bank as a high-speed substitute for mass storage, I discovered that switching banks to write each byte would corrupt  the bank switched out. It wouldn't be a problem to buffer the data in the static RAM, but I didn't see why it should be losing the data when switching for every byte.

While I analyzed the schematic, Giselle tried it out, quite happy at being able to try out some of the larger BASIC programs she had found in a book at the library.

I couldn't find the problem by just analysis.

*****

Tuesday, I dropped by Dr. Brown's office to ask if I could borrow a scope again to analyze the problem. He said I could.

That evening, after homework and before scriptures, I looked more carefully at the 6844 direct memory access controller. I wanted to see if there were some way to squeeze it into the Micro Chroma 68, to reduce the I/O burden on the CPU if I added a floppy disk controller. It was clear I'd have to perform an extensive bit of surgery on the Micro Chroma 68's printed circuit board in order to hook it in.

So I set that idea aside and started working out the EPROM programmer from the EPROM application notes. Realizing I needed more than the 5 volts that the simple power supplies Denny and I had built, I dug through the spec sheets and application notes that Denny had given me and looked at a switched mode power supply controller's application notes.

Wednesday, with Dr. Brown and the classes observing, I determined that the 6821 was drawing more power than I was giving it when I switched it that fast, which took power away from the dRAMs. Adding a decoupling capacitor on the memory board, and running an additional power and ground pair of wires to the RAM board solved the problem.

(The real me never put a scope on the problem, satisfied with 32K of RAM that he was not thinking he would ever fully use. He seems to have preferred painfully slow progress on Tera he and more daydreaming (about CPUs, memory, peripherals, and code) to generating actual code. Daydreaming. (Speaking of which,  the timing on getting the real world Giselle involved with computers was much later, and involved a different CPU. And didn't get as good traction.) So it might have been power problems, or it might have been timing, or I may have gotten the strobe and the bank switch line crossed up somehow. Until I can un-mothball the old Micro Chroma 68 I built up in the real world, I have no way of knowing.)

At the library, I made a copy of the dRAM circuit diagram for Denny, with notes on the power requirements.

When I got home, I called the IBM office, and the receptionist set me up with an appointment for the next week, instructing me to prepare something written about what I would like to accomplish during the internship. She didn't give me any clues about what kind of goals might be appropriate, said that was part of what they would be judging my application on.

With the RAM circuit settled, I added ROM sockets to the same perfboard, using more of the 6821's output bits and some logic to select the ROM socket to enable. Since the EPROMs I had were 4K, I wired the sockets to be addressed as 4K EPROMs.

While I was at it, I moved the BASIC ROM to the memory board so that it would be close to the circuitry I was using to switch ROMs in and out.

I considered combining four exclusive-or gates on A14, A13, A12, and A11, with four bits of parallel port, to allow switching between the two banks of RAM 2 kilobytes at a time. It wouldn't allow moving the 2 KB segments around in the memory map like the 6829 would, but it would give me more flexibility in using what was there.

Ultimately, I decided I didn't know what I would be using it for, and adding the XOR gates to the addressing would be simple enough to do later.

*****

On Thursday, after delivering the papers, Mom and I were in the kitchen. I was waiting for some toast to pop up, cutting a slice of cheese, for a snack to fuel my work on the EPROM burner design.

Mom was working on Dad's and her income tax records on the kitchen table.

Giselle snuck in through the living room, with a suspicious expression and a squarish load in a plain brown paper grocery sack under her arm and went straight to her room. She returned to the living room, sans load, and announced that she was not, under any circumstances, to be disturbed, then returned to her room and shut the door.

"What do you think is in the box in the bag?"

"Looks about the right size to be a Color Computer," I guessed, semi-randomly.

She nodded and went back to her bookkeeping.

Twenty minutes later, I was back in my room sketching out a tentative design and writing out a parts list, when Giselle came in looking frustrated.

"I need your help. But you have to promise not to tell Mom and Dad."

"Sure. I'm sure you'll tell them yourself anyway, and I'm sure whatever it is can wait until you do. But, just so you know, Mom and I already guessed it looked about the right size for a Color Computer."

"Well!" She stood, arms akimbo, angrily staring at me.

"It was a guess. Giselle, we know you're not going to do anything bad, so just take your time, and if we guessed right just pretend we guessed wrong. Okay?"

She turned without answering and left. From the hall, she called. "Are you coming?"

"Coming."

Spread out on her bed were a Color Computer with only 4 KB RAM, manuals, a program pack cartridge, and a 64 K RAM upgrade kit. "It was on sale," she explained.

"You want me to install the RAM upgrade."

"I want you to make sure I turn it on right."

"Okay."

"Then install the upgrade."

I obliged, fetching my tools and my TV from my room. After letting her check that it turned on okay, I carefully removed the "NO USER SERVICEABLE PARTS INSIDE!" sticker over the middle screw in the base without tearing it, and opened the case up. I may not have been a Tandy service technician, but I sure wasn't just an ordinary user.

Pretty soon we had the 64 K RAMs swapped in, the circuit board modified as necessary, and BASIC showing its welcome message once again on my TV screen. Giselle checked how much RAM she had:
PRINT MEM
24871
"That's not 64 K!"

"True. But that's what half of 64 K looks like after BASIC reserves the RAM it needs and the display RAM. The top half of the RAM shadows the ROMs and ports. To use the full 64 K, you'll need to either copy the BASIC ROM into RAM or use OS-9. And you'll still not be able to access something like 8K, I think."

"OS-9 needs floppy disks."

"Yes, it does."

"So what do I do? I don't have any more savings I dare spend."

"Good question. But you can always use the RAM you do have for whatever you were going to do with it."

"I bought a word processing cart."

"Sounds good."

"I want to run a business typing. How do I print?"

"I don't know much about business, but you need a printer, and your own TV for display, too. I think it's time to consult with Mom and Dad."

She looked at me with a thoughtful face.

"Okay."

And she went in to get Mom.

I watched for a few minutes while she and Mom used my TV and cassette recorder to get familiar with the new computer and word processing cart.

Her word processing cart used the Color Computer's highest density graphics to produce true lower case letters on the screen, and to make preview modes available, where you couldn't see the actual text, but you could see how the text would spread across the page.

Mom asked questions as Giselle tried things, and Giselle let Mom take her turn. Shortly, Giselle had the basics of the word processing cart mastered, and had typed in and saved some sample documents. I went back to my room to work some more on the power supply a little before Dad came home and came into my room.

"Hi, son."

"Hey, Dad. What's up?"

"I need your help. Wheres our Mommy?"

"She and Giselle are ... in her bedroom discussing some things."

Dad ducked out of my room, and I heard him start chuckling quietly in the hallway. Then he came back in my room. "Looks like one of my questions is settled. Can you come give me a hand?"

"Give me a minute to complete my notes and I can."

"What're working on?"

"Need a different power supply than what Denny and I built, different voltages for all the stuff I want to hook up."

"Will you need it for a printer?"

"Depends on what kind of port the printer has. Are you thinking of buying a printer?"

"There was a, I think you called it a dot matrix printer on sale at Radio Shack."

"Oh."

I finished the line I was drawing and went with Dad to the living room.

"Three hundred on sale." Dad frowned. "If it won't work, we can take it back today."

I looked at the box and saw that it was one of the printers that had both a standard parallel interface and a serial interface specifically designed for the Color Computer.

"This will definitely work with Giselle's new tools."

"Well, that's good to know."

"I'll need to wire up my own ports to use it with the Micro Chroma 68, but it should work okay with that, too."

"Then we'll keep it."

"If you think the family finances are up to it."

Three hundred dollars in 1981 was about twice what I brought in on a good month with the newspapers, and about half what I could make at a good job in electronics repair. It was more than Dad and Mom's monthly payments for the house loan, but that was because they took the loan out in the mid-1960s. A new house loan at the time would start about three hundred.

 "We'll be okay."

"I upgraded Giselle's computer to 64 K, but she still needs a TV monitor and cassette recorder of her own before she can start using it for real."

"Ah. Yes. I should talk to your mother. He turned toward Giselle's open door. "Max? Can I have a word with you?"

Giselle started and turned around with a guilty look on her face.

Dad grinned at Gizelle. "Hi, Zee."

"Uh, hi, Dad?" She swallowed.

"Nice day for new tools, isn't it?"

"Uhh ..."

"What do you need, Ted? Giselle and I were exploring her word processor program."

"Won't take long." Dad indicated the living room with his head.

"Just a minute, Giselle."

I went back into my room, to allow Mom and Dad to consult in private. I didn't have time to remember what I was doing before Dad called me into Giselle's room to help hook the printer up.

Giselle's test documents printed nicely, and we were all pleased.

"But I understand you need a TV monitor and a cassette deck of your own."

"Well, ... yeah. I do."

"If I bought them, would you mind sharing? Letting me work on my class handouts and tests when you aren't busy?"

Giselle's face lit up. "I could do that!"

So we went back to Radio Shack and picked out a TV and cassette deck, checking the demo units to see that they worked well with the demo Color Computer.

Back home again, I called Denny.

"Now what?"

"Got the dynamic RAM working pretty cheap."

"Oh, yeah?"

"Used the VDG for the refresh counter."

"Heh. Send me the diagram?"

"Tomorrow. I'm looking at the EPROM burner and other I/O, and we need power at other than 5 volts. So I'm looking at building a switcher."

"Are you sure you want to do that? Why not just do a voltage doubler?"

"Voltage doubler, switch mode, same stuff happening, .... Hadn't thought of that. Would be a bit less of a reach."

"Well, yeah. That's the point. Get this built so you can use it to help build your real computer."

I thought for a moment more. "I guess I'll look at it. So, what I'm really calling for, I'm thinking your surplus store is going to be the best place to get a UV EPROM eraser and a raw disk drive."

"You're wanting to come down for the three-day weekend ...?"

"Was thinking next week or the week after, actually."

 "Why not jump on it now?"

"Giselle has bought herself a Color Computer, and Dad and Mom have bought a TV monitor and cassette recorder for her, and she's going to be wanting help this weekend."

"She's what? No, no, she's supposed to wait until we've built our super-duper computers and use them!"

"Heh."

"Well, ..., okay, tell her I forgive her. This time. And to have fun with it."

"So, ..."

"So next week will be better for me than the week after. Date?"

"Date."

(As noted previously, this whole episode did not happen at all in the real world. I don't know if Giselle would have taken to the Color Computer as readily as this, if it had. Giselle got her first computer while I was on my six-year break from BYU, and Dad and Mom got their first computer after Chika and I moved to Japan. I also got my first printer during that six-year break.)

*****

Over Friday, Saturday, and Monday, I got voltage doubler circuits working for RS 232C and the EPROM, and I wired the fast cassette interface, a parallel printer port, and a couple of serial ports on one perfboard. The parallel and serial ports worked fine for the printer, with a cable adapter for the serial port. The fast cassette interface also seemed to work fine, but I wanted to take it in for tuning the next week.

I used my own text editor and text processor to write up a résumé and a proposal for the internship, focusing on my experience in electronics to that point, my progress on the Micro Chroma 68, my interest in using Japanese on computers, and on my interest in how things were done at IBM, saved them on the slow cassette and the fast cassette, and printed it all out on the new printer. It was visibly dot matrix, but still quite legible.

And Dad got some class handouts worked up on Giselle's computer, and Giselle started putting samples together for showing potential clients.

*****

I somehow made time to go to the Valentine's Day dance on Saturday and play softball with the church young adult group on Monday.

Neil's little sister, Niki, with encouragement from her brother by mail and promises of help from me and Br. Orange, was handling the sound for the dance. Br. Orange and I spelled her at the turntable so she could go dance, and she enjoyed it and decided she could start doing it regularly.

Of course, I danced three or four with her. Five years' difference seems like a lot when you're twenty-one or sixteen.

There was a young woman named Brandy who had come to earn college money working in the oilfield support for a year, who claimed a few dances with me and spent some time hanging out around the turntable when I was on it. Very interesting person, very strong personality. If you called her cute, you had to have your wits ready, but she was pretty good-looking.

She came to play softball on Monday, and when she hit a homer with two on in the eleventh inning and our side won, I cheered with "That's my woman!"

She politely but firmly informed me she was not my woman when she came in to home plate, and I filed that particular cheer away as one not to use without considering how the woman I was cheering might perceive my interests.

Maybe "That's our woman!" would have been better, but somehow I doubted it.

*****

"That's a computer?" Mike's face showed his doubt.

I had brought the Micro Chroma 68 to Tuesday's BASIC class, to pass off the previous week's assignment of an amortization table, and most of the students were gathered around where I had set it up before class started. It was showing the TVBUG monitor ROM prompt on the screen.

"No, it's a wooden box with a computer inside it," Pat rolled her eyes and shook her head. "Of course it's a computer."

I chuckled. "It's a work in progress, but, yeah, it does have a microcomputer in there."

"No operating system?" she asked.

"Not yet, not unless you can calll a debugging monitor an operating system."

Don looked puzzled. "What's an operating system?"

Prof. Bright cleared his throat behind us. He had come in to get a look at the Micro Chroma 68.

Prof. Crane chuckled. "Don, do I need to put that question on the final?"

"No! Wait. Is it the thing where we log in on the Univac and then give it the command to run BASIC?"

"By me, I think he's got it," George intoned in a British accent cobbed from Monty Python or Dr. Who.

Prof. Bright nodded. "Very good, Don. That's the boot ROM giving you some kind of prompt, right, Joe?" He was clearly prompting me.

"Yeah. It's a debugging monitor, so it accepts debugger commands. I have Tiny BASIC in a ROM, there," I lifted the cover and pointed at the ROM, visible on the memory board. "So I can just give it the command to jump into the ROM at the right place, and it will boot BASIC." I demonstrated, as I had for my family, and the Tiny BASIC prompt came up. "Although, really, considering the amount of ROM in the thing, it's hard to call this guy's startup process bootstrapping."

Prof. Crane tilted his head. "Why would you say that?"

"The monitor, tape interface, and the BASIC interpreter are all already resident in ROM, not read into RAM from tape or disk or some persistent storage device. There's no sense of the computer 'raising itself by its own bootstraps to a usable state'. All it is does is initialize some variables so code that's already there can run."

Prof. Bright nodded. "But initializing the variables is something it does for itself, right?"

"Well, I guess I can grant that."

"So," Prof. Crane asked, "can you fix it so it goes from the monitor to BASIC without typing that monitor command in?"

I had to think for a moment. "I don't recall seeing code where the monitor checks for a other ROMs to execute, but I couldn't swear it's not there. There are a couple of diagrams, I think, for circuits to change the reset vector."

"Doesn't the reset process do some bootstrapping in the CPU itself?"

"I'm sure it does, but Motorola hides that pretty well. It's a black box." I thought for a minute. "I am planning on getting floppy disks and purchasing or writing an operating system for this computer. When I do, I'll have to write drivers for the floppy disks, at least. Initializing the drivers before reading the OS from the floppy will make starting it up a bootstrap process."

"Something like this?" Prof. Bright draw a state transition diagram on the whiteboard:
reset -> monitor -> driver init -> OS
I nodded in agreement. "Something like that."

"So," Pat asked, "What OS are you thinking of? CPM? Unix?"

"I've been looking around, and it looks like the best suspect is an operating system called Flex. I don't really know much about CPM or Unix, but I haven't seen either available for the 6800."

"I've been using both at work. Unix comes with source code, and lots of people are implementing CPM from the specifications and documentation."

"Source code? What's the CPU?"

"The computers are PDP-11s, but the source code is in C."

I looked at Pat expectantly.

She didn't add anything.

"See what?"

 "C language. The programming language, 'C'."

The words I heard were "See language. The programming language, see?" But the intonation was not "see" as an imperative, but as a name. I had to process that.

"It's not in PDP-whatever assembly language? The name of the language is 'See'?"

"Right. 'C'. But some of it is in PDP-11 assembler."

More questions came to mind. "What is the PDP-11's CPU?"

"Uhm, PDP-11?"

The professors were listening to the exchange in amusement, but Prof. Bright took pity on me about the processor. "PDP-11 is a mini. I understand the 6800 register model and assembler are modeled after the PDP series somewhat."

"So a PDP series minicomputer processor." I nodded. And most of the operating system is written in a high level language called 'See'."

Prof. Crane took further pity on me and wrote the letter 'C' on the whiteboard. "'C', see?"

I chuckled at the joke. "Now I see."

Pat nodded and some of the other students laughed nervously.

"Ah, time to start today's lesson. Past time, even. Let's get our textbooks out." Prof. Crane asked if there were any questions, then started us discussing roots of equations in preparation for the Newton-Raphson project.

After class, he checked my program and the output. "You know, it would be easier to grade this if I had a printout of the source to look over after you take the computer home."

"Ah. Yeah. We bought a printer." I dug the two-page printout out and handed it to him.

"Oh. Great. Thanks."

"So what do you think of porting Unix to it?" Pat was waiting around, very interested in the computer. Several of the other students were also hanging around.

"I haven't seen any advertisements for a C compiler for this."

"Oh." She seemed disappointed. "I guess you're not interested in writing a compiler yourself?"

"I've seen those railroad track syntax diagrams for Pascal, but I haven't even seen a programmers manual for this C language. And I guess I need something fairly easy to start on, to bootstrap my understanding of how to write such things."

Prof. Bright had returned, and was listening. "Do you think you might like to write a compiler?"

I thought about that. "Sure. Maybe. But it has to be something that doesn't require tools I don't have."

He and Prof. Crane exchanged glances.

"What would you suggest, Rusty?"

"Languages built on lists can be easy to write. LISP has a bit of a steep learning curve. Snobol was fun, but I have no idea how to get information on it. Forth is a bit easier, and there's the fig -- the Forth Interest Group -- giving information out for the cost of copying it."

"Ah, Forth. That's stacks and RPN. You were saying you like Hewlett Packard calculators, weren't you, Joe?"

I had said such a thing, and my interest was piqued.

On the way home, I dropped by the library to see if I could find information on Forth or the Forth Interest Group, and again I found an ad from Mountain View Press, in Dr. Dobb's Journal. Again I took a copy of the ad home with me.

At home, I delivered the newspapers first because Mountain View Press was in California, and I could call after six o'clock local time and get cheaper rates. I got the information I needed, and wrote out an order for hardcopy of the 6800 model source code and the installation manual, and a copy of the source code on cassette tape in Kansas City format.

Chapter 9: Headwind

[Backed up at https://joel-rees-economics.blogspot.com/2020/02/bk-33209-bootstrapping-or-baby-steps.html.]

No comments:

Post a Comment

Keep it on topic, and be patient with the moderator. I have other things to do, too, you know.