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...

Saturday, January 25, 2020

Backup: 33209: Possible Uses for the Micro Chroma 68

Backup of https://joelrees-novels.blogspot.com/2020/01/33209-possible-uses-for-micro-chroma-68.html.

Chapter 4: Micro Chroma 68 Lives

Chapter 5: Possible Uses for the Micro Chroma 68


After classes on Monday, for family home evening, I decided to show Giselle and my parents a few things we could do with the Micro Chroma 68 as it was, using the Tiny BASIC interpreter as a calculator.

Mom leaned back and pursed her lips, looking at the screen where Tiny BASIC had replaced the monitor ROM's title screen with its own. "What's 'Copyleft' mean?"

"It means they explicitly give people permission to copy and modify it."

Her expression remained doubtful.

Giselle gave me a curious look. "Wouldn't Microsoft have something to say about that?"

I nodded. "I'm sure they would have lots to say, if they could. Bill Gates and Paul Allen really would love to have everyone to think they own BASIC, but they don't. Give them time, when they think everyone has forgotten Dartmouth and all the independent implementations of BASIC that trace back to the original Dartmouth BASIC of the previous decade, and further back to ForTran, instead of to Microsoft's re-implementation, and I'm sure they will get around to claiming they invented BASIC."

"Then what is it they claim?" Dad asked.

"Right now, they are working hard to convince everyone that their version is, or should be, The Standard because they sort of beat a lot of others putting Dartmouth's language on a microcomputer, and that therefore everyone should contribute to their efforts to innovate their way into a computer empire to rival IBM."

Dad raised his eyebrows. "IBM's pretty big."

"Apparently, so's Bill Gates's ego. But IBM is also way behind the curve on the personal computer revolution, so it isn't exactly an unreasonable ambition."

Mom shook her head in bewilderment. "Okay. So you were showing us what this can do," she prompted.

"Oh, yeah. Calculator mode. Say I want to know how fast I need to average in the car, to get to Austin in five hours. It's 338 miles to Austin." I typed in
PRINT 338/5
and it printed out
67.6 OK
"So I gotta break the speed limit to do that." Back then, we still had the double-nickle, 55 MPH speed limit on all public roads in the US.

"True," Dad nodded. "Can I try it out?"

"Go ahead." I stood up and let him sit down at the keyboard. "Be careful not to move the mainboard. I really need to put this in its own box."

Dad played around with calculator mode for a few minutes while Mom and Giselle watched. Then he nodded and stood up. "I see, it calculates," he said with a grin and a nod.

Giselle looked like she wanted to try it.

"Your turn." I gave her an encouraging nod.

She sat down and tried a few calculations of her own, then stood up and turned around, her brow knit. "Oh ... kay, it could be fun. Your turn, Mom."

"I'm impressed that it's a calculator."

"Oh, try it," I urged.

Mom hesitantly sat down at the keyboard and thought for a moment, then said, "Okay, 4 cups of flour for three dozen cookies, and I want to make only twenty. So, divide is the slash, and times is ..."

"Asterisk."

"Okay."
 4/(3*12)*20=
SYNTAX ERROR
"Well, I know what syntax is, but what is it trying to tell me?"

"Instead of writing it like a test problem, just tell it to print, and give it the formula. Type 'print' and then the formula."

So she tried it that way:
PRINT 4/(3*12)*20
2.22221 OK
"Okay, I can believe that. What else can it do?"

"We can put that in a loop:" I traded places with her and typed in a short program
10 PRINT "COUNT OF COOKIES";
20 INPUT C
30 PRINT 4/(3*12)*C;  " CUPS OF FLOUR"
40 GOTO 10
RUN
COUNT OF COOKIES? 50
5.55556 CUPS OF FLOUR
COUNT OF COOKIES? 15
1.66667 CUPS OF FLOUR
COUNT OF COOKIES?
"Well, that's interesting. Can it do that with a whole recipe?"

"Let's see the recipe."

I hit the break key to stop it while she found her recipe cards.

"Let's try these biscuits." She showed me the card.

I read it and mumbled to myself while typing:
10 A=8 REM BASE COUNT
20 F=2/A REM CUPS FLOUR
30 P=4/A REM TSP BAK POWDER
40 S=(1/2)/A REM TSP SALT
50 B=4/A REM TBLSP BUTTER
60 M=1/A REM CUPS MILK
100 PRINT "COUNT OF BISCUITS";
110 INPUT C
120 IF C = 0 THEN GOTO 200
130 PRINT F*C; " CUPS FLOUR"
140 PRINT P*C; " TSP BAKING POWDER"
150 PRINT S*C; " TSP SALT"
160 PRINT B*C; " TBLSP BUTTER"
170 PRINT M*C; "CUPS MILK"
180 GOTO 110
200 STOP
The top line scrolled off the screen when I entered the last one.

I typed "RUN" and hit the enter key, and it came back with
COUNT OF BISCUITS?
So I typed in 100, and it immediately spat out 
 25 CUPS FLOUR
 50 TSP BAKING POWDER
 6.2500000 TSP SALT
 50 TBLSP BUTTER
 12.5000000CUPS MILK
?       
Mom laughed. "That's a lot of flour."

I looked at the last line, with its lone question mark. "Woops. There's a bug. That should have been GOTO 100." I pressed the break key and retyped line 180 and ran it again to check.

"Runs nicely. So this is what you do when you want to save a program." I hit the break key again

"I get the point. But, actually, you generally adjust the amounts slightly for large or small batches. Can the program do that?"

"Sort of. I can add the rules for it in the places where I'm multiplying by the count to make.

"But the cook also usually adjusts things to the weather, right?"

Mom nodded.

"The computer doesn't know anything about the weather unless we tell it, and that's another complexity.  BASIC is missing features to help deal with complexity. Tiny BASIC only has a very limited number of variables, anyway, and that can make it harder to work with. And if there are a lot of rules, this small computer can run out of memory to handle them all. Running out of memory for just this one recipe won't happen, but if we try to put a whole recipe book in the computer, we might."

"I see, said the blind lady," Mom laughed wryly. "Don't bother trying to explain, I understand it might be possible, and that's about good enough."

Then Dad asked, "So what about just typing?" 

"Word processing. There are text editors that I could tweak to run on this, and formatting programs. I could wire a port up to attach a printer to put the text on paper, but printers are kind of expensive, six hundred bucks and up if you want the output to look at all good."

"You can buy a decent typewriter for a lot less."

"True, but revising text on paper is not nearly as easy as on the computer screen."

"Okay, so how would it work? What would it look like?"

"Sort of like," I typed at the keyboard:
10 REM THIS IS A LINE OF TEXT.
20 REM I COULD TYPE ABOUT MANY TH
INGS,
30 REM EXCEPT FOR THE REM.
"Most word processors I could get for this computer require typing in a line at a time, and the lines have line numbers like the BASIC program does. But I'm typing 'R E M' here to keep BASIC happy. General purpose line editors wouldn't need that for word processing text."

Three pairs of eyes gave me blank looks.

"And formatting requires commands, like '.CE' to center a line."

Blank was replaced by clear doubt.

"That sounds a lot more complicated than the typewriter." Dad grinned. 

"There are screen editors for some computers ..." I thought for a little bit, then got out the datasheet for the 6800, reset the computer to the monitor prompt, and hand assembled a little input loop that did nothing but look for input characters.
1000 BE EE E1 JSR $FEE1
1003 20 FB       BRA *-3
Mom shook her head. "No way do I understand what you just did."

"There's an assembler that could do that for me. Denny wanted to send it home with me, but I'm worried about copyright, and I'm not sure I'm quite ready to use it. Although, I'm not sure you'd understand the assembler any better."

The four of us chuckled.

My hack worked, and I could move the cursor around and type anywhere on the screen.

"Let me try it."

"Okay."

Dad typed
1: HOW DO YOU SAY, "WHAT IS THIS?"
IN SPANISH?
"Now, if we had a printer, I could print that?"

"Not with just the code that is there. I'd have to write more code to output it to the printer. But the screen's only 32 columns wide, and that's going to make it hard to see how it will look on the page."

"Can I save it on a cassette tape?"

"No. That'll need more code, too."

Mom was looking puzzled again. "You talk about code a lot."

"Program code. Without programs."

"Where do you get the code?"

"If what you need already exists and is being sold, you can buy it. If not, you make it yourself."

"Would you have to write it all yourself?" Dad asked. "I guess that takes a lot of time."

"If it doesn't already exist."

"So, does this word processor exist?"

"Well, the manual for this kit mentions Technical Systems Consultants, and indicates they have a text editor and a text processor that can be easily modified for it. I'm not sure how much they want, and I'm sure it's a line oriented editor rather than a screen editor."

Giselle took a deep breath. "So this computer is not going to be easy to use?"

"Not really. Apple IIs will be a bit more tame. And Radio Shack's Color Computer gets some ease-of-use points in some circles."

Dad raised his eyebrows. "So, what about those?"

"Well, that's no fun, using something someone else made."

"You don't put food on the table with fun."

"Some people do."

Dad's brow wrinkled.

"So could you make money as a typist with this?" Mom asked.

"Somebody might, but that's not what I plan on doing."

"So what do you plan on doing with it? Is it ever going to make you money?" Dad's voice betrayed a bit of exasperation.

"Right now it's just for the microprocessors class I'll be taking, and for a calculator for physics and math classes. It's not about making money directly, it's about opening doors to better paying jobs, if you have to look at it that way."

"Do you need the calculator for those classes? What happened to your TI?"

"The TI calculator died, Dad. I shouldn't have taken it to Japan with me."

"How much would a new one cost?"

"Less than the floppy disk drives and the software I need to get this computer running right, Dad. But the calculator won't teach me how to program microprocessors."

"But the microprocessor lab will."

"The 8080 practice kits in the lab won't teach me how to work with the 6800. Engineers use the 6800. Accountants use the 8080. And if I wanted to make a living as a computer accountant, I'd be taking classes in the EDP department, from Professors Crane and Bright, along with certified public accountant coursework."

(The real me could not put this into words, and, in fact, ended up getting his two year Associate's degree from the Electronic Data Processing department, after taking classes in Pascal, ForTran, and CoBOL, database programming, and such while waiting for the assembly language class to make because he had skipped too many electronics classes and had run out of classes. He did not take the CPA coursework, however.)

"I just don't want you eating dirt and going naked ..."

"Like Professor Brown says inventors do. I know. You didn't want me to be a starving artist, either."

We looked at each other in frustration. It had been a while since either of us had allowed the wall to go back up, and both of use were trying to figure out a way to get it down without compromising the wrong points.

"Dad, the vultures gather at the carcass to get scraps after the bigger beasts take their share. They do their part for the economy. But the eagles are the ones who take the prey and get their pick of the meat. This is my chance to be an eagle."

"Being an eagle is lonely work."

"Dad," Mom interrupted, "Joe needs to do this. If nothing else, let him get it out of his system."

Just get it out of my system. That lack of faith shook me.

Hallmarks of the criticism of the world, coming from my own parents.

I wanted to be brave, to appreciate that they were worried about me, about my future. But the perceived criticism ate at me.

The prototyping kit was beginning to look like the fruit of knowledge of truth and evil in the Garden of Eden. At any rate, it was becoming the focus of the disparity I felt between my parents expectations, society's expectations, and the course I felt I should pursue in life.

I could not put my finger on the exact nature of the course I thought I should be taking, and the adversary of my soul was using that fact against me, as well.

The real me ultimately gave in to imagined pressures and let himself be washed into EDP, leaving the prototyping kit as a sort of hobby.

The me in this story went outside to take a long walk and cool down.

When I came back, Dad was grading his students' homework. I went into his study.

"Dad, can we talk?"

"Sure, Son." He refrained from his usual jokes.

"One day soon, everyone will have at least one computer. What we are doing now is inventing the ways people will use them. The big companies want to use them to harness the power of the masses. I want to make it possible for individuals to escape the harness."

"That's a powerful ideal."

"Yeah, and powerful ideals can burn you when mishandled. I know."

Dad gave me a sharp look.

"Yeah, Dad, I figured that out all by myself. But there is also the parable of the talents. I don't want to be the guy who buried his talent."

Dad picked up his Bible and turned to Matthew 25 and reviewed silently for a few minutes.

Mom came in.

Dad began again. "Have you considered what Fred Burns suggested about IBM?"

"Well, yeah."

"I think you need the money."

Mom interrupted. "I can take the paper route back over for summer, so you don't have to give it up to do the internship. But isn't there something else you want to do this summer?"

Dad and I looked at each other.

Mom continued, "There's a picture of a cute Japanese girl on your desk."

"Satomi's engaged."

"That's not nice of her." Giselle had come in now, and looked rather put out.

"Or it's just being sensible." I shrugged. "Cross-cultural marriages are hard."

Dad nodded in agreement.

Mom's face became a mask. "Your ma doesn't particularly want you moving back to Japan, but you need to follow your heart."

"Cel, ..." Dad started to say something, then stopped. Then started again. "I think Joe needs to know something we really haven't mentioned to the kids."

"That was different."

"Women usually prefer their own country."

Mom sighed. "Okay. Giselle, you may find this a little distressing."

Giselle was indignant. "I think should know if Joe should."

"Okay, go ahead, Dad."

Dad took a breath. "You know I spent time after the war in Italy."

"Yeah." He had told me a little of his experiences after the war, translating for treaty negotiations all over Europe. "You've mentioned driving through minefields with live ordnance rounds flying overhead."

"There were a lot of people over there going hungry."

"I know about that."

"Many of the soldiers would find ways to help."

"Dad, you would never do anything wrong." Giselle was somewhat distressed.
I was not sure how to take the information, either.

"She did not want to leave Italy. I did tell your mother before I asked her to marry me."

Mom nodded.

"You may have a stepbrother in Italy. With Mom's permission, I sent some support money every month until she wrote and told me she was able to get enough work to support them both. I still write every now and then, to ask how things are going."

"So, what you're telling me is that I should be sure I can handle living over there if I go making commitments over there, right?"

Dad sighed. "Something like that. I did not want life to be hard for you Joseph, but it looks like it may end up hard anyway."

"Hey, I wrote Satomi and told her congratulations. It's not like things are going to go anywhere further for me there."

That was really as far as I had thought about it at the time.

"Are you sure?" Mom gave me a tilt of the head. "When you marry, it's best to be able to give your whole heart."

"Well, I settled my feelings about Beryl, I think. And I'm not sure what I felt for Satomi goes beyond just a big crush. She helped me in much the same way Beryl did, encouraged me to try at something I was balking at. Love, but not marrying love."

The furrows in Dad's brow deepened.

"I think I was wrong to not let Denny send software home with me," I muttered, half to myself. "Test drive before you buy. Oh, well, I'll get what I can working, and go down again, or just order the software."

I looked up at Dad. "And I'll look into the internship thing. And think about going back to Japan to see if there is something there I need to look more carefully at."

Dad hesitated. I waited.

"Could we go look at the Apples and the Tandys?"

"Sure. This week?"

"Friday afternoon?"

"It's a date, Dad." We gave each other awkward smiles.

Chapter 6: Mary Had a Micro Chroma 68

[Backed up at https://joel-rees-economics.blogspot.com/2020/01/bk-33209-possible-uses-for-micro-chroma-68.html.]

Thursday, January 16, 2020

Backup01: 33209: Micro Chroma 68 Lives!

Second backup of https://joelrees-novels.blogspot.com/2020/01/33209-micro-chroma-68-lives.html.

 Chapter 3: School

Chapter 4: Micro Chroma 68 Lives!


It took me until the last weekend in January before I had saved enough money for the gas to Austin and the keyboard, and a few other things I could only guess at until I got there.
 
Friday the 30th, after classes, I got the timing light out and tuned the engine of the family station wagon, a 1971 model Mitsubishi-made Dodge Colt, and headed out. In Japan, the model type is called "light van", but you'd probably recognize it as a compact station wagon. It had a five-on-the-floor manual transmission, and the Mitsubishi engine was really fun to drive. But the heater didn't work, and the aging engine had to be tuned regularly.

We had weather warnings for a cold snap, and the temperature headed down as I drove past Midland and  turned south, plummeting as I drove through Big Spring and Sterling City. I stopped after Sterling City to get my sleeping bag out and wrap my legs in it.

The sleeping bag helped as far as the by-pass around San Angelo, but I had to leave my legs free enough to operate the gas, and to reach the clutch and brake if there were an emergency. Wall and Eden had speed zones and required dropping to 30 MPH (50 KPH), which is not a fifth gear speed, and both had stops, too. Keeping my legs wrapped there was not possible.

I could not protect my feet from the cold.

I wondered if God were telling me to not to do this, or if He were letting the devil try to stop me. Or if he were just seeing what I would do in bad weather, for grins.

With the wind-chill, it was well below freezing in the car, and my feet were beginning to feel a little frostbitten when I pulled into a motel parking lot in Brady, about an hour and a half, maybe two hours out of Austin. I was losing body heat fast, and had the shivers. It was either pay money for shelter or set up some sort of real camp, and, while I had the sleeping bag, I really wasn't prepared for camping in sub-zero weather.

I had to spend precious money, ten dollars for the night. (What would it be now with inflation, huh?) But the room had a heater, and was warm enough with my sleeping bag over the covers. I called Denny to tell him where I was, and he called Mom and Dad, to save me the cost of the second long distance phone call from the motel.

To keep myself occupied while my body and feet warmed up, I studied the Micro Chroma 68 manual and some of the other datasheets under the covers a bit before I went to sleep. I also got up and plugged the board into the hotel room TV to get a look at the output in color, just for the funstrations. Moving around the warm room helped the circulation.

Micro Chroma 68 Monitor ROM Boot ScreenColor

It felt strange to see the monitor prompt me, and to not be able to type commands.

Frustrations helped warm me up that night.

The real temperature got down below zero Fahrenheit (below -20 Celsius) during the night, and then warmed up enough to snow by six o'clock, when I woke up. But the clouds had broken, and the sun was warm when it rose a bit before seven. I had a bit of tailwind, the roads were clear enough to drive at half-speed until the passing of cars melted and scattered the snow, and the car and I were okay for the rest of the trip. By the time I got to Austin, the streets there were  completely clear of snow.

Denny had some chores to finish for Denise, so I checked his wiring while I waited. And I looked over the heavy-duty voltage regulators he had gotten for the power supplies and the three millimeter aluminum plating he had gotten for heatsinks.

When he finished his chores, he got out his drill and router, and we cut and drilled the heatsink plates and mounted the voltage regulators and wired up the improved power supplies, and then we checked his board.

It didn't boot, but we found the problem quickly. He had done some soldering late at night and left a solder bridge across a couple of the ROM socket address pins.

Then we looked at the Micro Chroma 68's diagrams and code again, to get as good an idea as possible of what we would be looking for at the surplus shop.

After that, we went out and both crawled under his Fairlane coup, and we spent an hour replacing the transmission, talking about what we would need for the computers while we worked. When we had the replacement tranny installed, we test-drove it around the block. Finally, we cleaned up and drove the car to the surplus shop, for a longer test drive.

Denise was happy to send us on our way, glad to have two cars running again.

John Phillips, the proprietor of the surplus shop, was a former employee at Motorola, and another friend of Denny's.

"Keyboards are all in these bins and on these shelves over here."

"Documentation?"

"What you see is what you get."

None of the keyboards had any documentation.

"I like this keyboard." Denny held up one.

"104 keys. Kind of big. Microcontroller controlled." I gave him a lop-sided frown.

"That keyboard does not produce ASCII codes," John commented. He didn't have documentation, but he had the necessary information.

"So it would require some serious customization, like programming our own controller."

"Guess we'd better pass on this one." He put it down. "Here's one with no controller at all."

"So we'll have to add a ROM for decoding the keyboard, and patch the monitor ROM to call it. Do you have an EPROM burner?"

"Guess not, not yet. That's something we have to build."

"Yep."

"Hmm. Maybe put some LSI latches and shift registers on a perfboard? Oh. Here's a Cherry."

"Nice. but I was hoping to leave a little money for other things."

"Yeah, Den won't like that price. Here's a 56 key keyboard with some simple LSI."

"I like the layout. But there're no cursor keys."

John commented again, "That one puts out 7 bit ASCII with a negative going strobe. They were extras left over from a teletype machine production run. Pretty much like a Cherry keyboard."

"BINGO. Price is good. Do you have two?"

"Yep." John rummaged around in the bin, and pulled out two still in bubble-wrap.

We picked up the keyboards and took them to the counter, then went wandering around some more.

"Here's a ten-key pad with cursor keys." I picked it up and showed Denny.

"Do we need it?"

"I think I'll want it. Cursor keys, as much as the numeric pad."

Denny picked one up and looked it over. "Price is not too steep. Maybe I should get one, too."

"Oh, and here are the zero insertion force sockets for the EPROM programmers we need to make."

"ZIF. 28 pins?"

I checked. "24, 28, and 40 pin."

"We should be able to do 24 pin ROMs with the 28 pin socket. Snag me one of the 28 pin sockets."

"I'm going to get the 40 pin socket, too, for programming 68701s."

"Good idea. Get me one, too."

I picked up the sockets.

"Are you interested in EPROM eraser beds?"

"Sure."

John pointed us to another table, and we looked at them.

Denny's forehead wrinkled in a frown. "I'll bet we could make our own for that price."

"Getting the lamp at the right wavelength is the problem."

"Hmm."

"That stop at the motel last night leaves me short of the price. Maybe next time."

"How much short?"

"Ten bucks."

"I can take that off."

I scratched the stubble on my chin. "Cutting it too close on my budget. I'll take my chances that you'll have one the next time we come."

Denny chuckled. "Oh! Silly scope!"

John laughed.

"Our dad's pun."

"I see."

"A hundred dollars is not bad, but I don't have that much. And it only goes to 1 megahertz. We need ten megahertz minimum."

John showed us a couple of hundred megahertz capable scopes, but they were way beyond our financial resources. I wrote the prices down, anyway.

"Tape drives." Denny lifted one for inspection.

"Cool. Not this time around, though."

"Actual data cassette drive." He looked at the price tag. "Ouch. Definitely. That's too rich, too."

"I can give it to you for half that price."

Denny shook his head regretfully. "Still more than either of us can afford."

"Yeah, and if I had that much, I'd want a floppy drive, instead."

"We have some floppy drives over here." John showed us another set of shelves.

We looked at the drives. "Chassis, motors, screw gear and head assembly, no electronics besides the head."

"Yeah, there's too much we'd have to develop ourselves, and no tools yet to do it with. Need the scope to align it. But a nice price if we had the tools and the time."

"I'd have the money if I hadn't had to stop at the motel last night."

"That's the best you're going to find, at least this year."

Denny shoved his lower lip to the left in thought. "Dean Brougham has that high speed tape design he was telling me about."

I set my jaw to the right. "I guess it would give us some practice with extracting data, in addition to faster persistent store?"

John nodded. "The encoding and modulation won't be the same, but it would give you something to store programs and data on and share them. I must admit, I'm not sure I'd be able to get one of these to work."

We stopped at the UT campus on the way home, and I picked up course catalogs and other materials.

Back at the house, Denny told me to dig out a record to put on the stereo while we worked.

"Deep Purple? Since when were you into hard rock?"

"Thought it was something else. Den kind of likes 'Hush', though."

"No, you do." Denise laughed.

"Heh. Sometimes. But I can't handle listening to the whole album."

"Thinking of the 'Deep Purple Dream' cover by Stevens and Tempo?" I sang a few lines and hummed a few bars.

"That's one I like," Denise gave Denny a significant look.

"But it's not what I was looking for. I thought I bought this for 'Hush'."

"How about Herman's Hermits cover of 'A Kind of Hush'? Or maybe the Carpenters' cover?"

"Dang, that sounds like it might be it."

I sang a few lines of that, too.

"Write those down for me. When we get some extra money, I'll get them for Denise for her birthday or Christmas."

"Promises, promises." Denise smiled wryly, and I quietly promised myself to save up some money for the records.

(In the real world, I couldn't drag the names of either song out of my memory at the time, and it was a long time before I was able to spare any money for music again, even though I had bought some hundred or so albums of various genre before my mission. Before my mission, I would have copied some of my albums to cassette tapes for them. After my mission, I was more careful of copyright.)

Over the course of the afternoon and evening, we got the keyboards working and used a voltmeter for rough-tuning the Kansas City Interface circuitry so that we could fairly reliably read program tapes Denny had from his friends, and we could read and write programs and data from each others' boards.

 "Don't want to take the assembler and editor programs back with you?" Denny held up a cassette tape.

I shook my head. "No, not really."

"I could burn them into a ROM for you at work."

"It's the copyright."

"How are you supposed to know if you want to buy it without test driving it?"

"Next time, maybe. I think I have plenty to do. Besides, I want to write my own."

"That's crazy talk."

"Everything I let someone else write for me is more software I can't really trust."

"Do you trust yourself that much?"

"Good point. But at least I should be able to fix it myself if it's something I wrote."

"Maybe."

"Need better options. Especially relative to software you won't be able to get the source code for."

Source code is what the program or program modules (often called "libraries") in human readable form is called. You run a compiler or an assembler on the source code to produce object code that the computer can directly run -- except for interpreted languages like many versions of BASIC, which have an text-level interpreter instead of a compiler, and the interpreter reads, interprets, and runs the source code directly.

"So, you'll only run stuff you write yourself, or stuff you get the source code for, as well?"

"Case-by-case, but I'm also pretty sure paying for the software gives me a better chance of getting the bugs fixed."

"Good point."

I went to the University of Texas student ward on Sunday, to meet people and see if I liked it. It was okay.

I checked over the UT catalog with Denny before I left.

"See, they have Japanese courses."

I read the descriptions. "I think it'll be repeat for me, but I'll think about it."

Denny shrugged and rolled his head back and forth on his neck. "If you're going to be that picky, it's going to be either BYU or Berkeley for you."

"Dad said he does not want me going to Berkeley."

"Cutting edge research in computers."

"Yeah." I raised my eyebrows and sighed. "I am considering Berkeley, too. You know, I'm thinking I should make a box for this computer before I start taking it to school."

"It's a good idea. What do you have in mind?"

"You saw the tea box I brought home from Japan?"

"The one you put all your albums in?"

"Yeah." My record album collection pretty much filled the tea box.

He grinned. "Metal lined. But it's a little on the big side for this computer, I think."

"True. I'm thinking of building a box shaped like a typewriter and lining it with sheet metal, like the tea box."

"Might work."

Before I left, Denny handed me a rail of 64 kilobit RAM chips with a broad grin. "Think you can figure out how to use these?"

I grinned back happily. "Tested from the recycle bin?"

"Yep."

"I definitely think I can figure it out."

When I got home, a letter from Satomi was waiting for me. She informed me she was engaged to an older returned missionary I had met once in Niigata on trade-offs, one Brother Fukumasa. I sat down and wrote a reply congratulating her and Brother Fukumasa, and realized I needed to think more seriously about going back to Japan.


[Most recent backup at https://joel-rees-economics.blogspot.com/2020/01/bk01-33209-micro-chroma-68-lives.html.
Earlier backup at https://joel-rees-economics.blogspot.com/2020/01/bk-33209-micro-chroma-68-lives.html.]

Backup: 33209: Micro Chroma 68 Lives!

Backup of https://joelrees-novels.blogspot.com/2020/01/33209-micro-chroma-68-lives.html.


[JMR202001161222: Backup]

Chapter 3: School

Chapter 4: Micro Chroma 68 Lives!


It took me until the last weekend in January before I had saved enough money for the gas to Austin and for the projected purchases.
 
I took off Friday after classes in the family Dodge Colt compact station wagon. It had a five-on-the-floor manual transmission, and was fun to drive. But the heater didn't work, and the engine had to be tuned regularly. I got out the timing light and gave it a tune-up before I left.

We had weather warnings for a cold snap, and the temperature headed down as I drove past Midland and  turned south, plummeting as I drove through Big Spring and Sterling City. I stopped after Sterling City to get my sleeping bag out and wrap my legs in it.

The sleeping bag helped as far as the by-pass around San Angelo, but I had to leave my legs free enough to operate the gas, and to reach the clutch and brake if there were an emergency. Wall and Eden had speed zones and required dropping to 30 MPH (50 KPH), which is not a fifth gear speed, and both had stops.

It was cold, and I could not protect my feet.

I wondered if God were telling me to not to do this, or if He were letting the devil try to stop me. Or if he were just seeing what I would do in bad weather, for grins.

With the wind-chill, it was well below freezing in the car, and my feet were beginning to feel a little frostbitten when I pulled into a motel parking lot in Brady, about an hour and a half out of Austin. I was losing body heat fast, and had the shivers. It was either pay money for shelter or set up some sort of real camp, and, while I had the sleeping bag, I really wasn't prepared for sub-zero weather.

I had to spend precious money, ten dollars for the night. (Inflation, huh?) But the room had a heater, and was warm enough with my sleeping bag over the covers. I called Denny to tell him where I was, and he called Mom and Dad, to save me the cost of the second long distance phone call from the motel.

To keep myself occupied while my body and feet warmed up, I studied the Micro Chroma 68 manual and some of the other datasheets a bit before I went to sleep. I also plugged the board into the hotel room TV and got a look at the output in color, just for the funstrations. Moving around the warm room helped the circulation, but it felt strange to see the monitor prompt me and not be able to type commands.

Frustrations helped me warm me up that night.

It got down below zero Fahrenheit (below -20 Celsius) during the night, and there was snow on the ground at six o'clock, when I woke up. But the clouds had broken, the sun was warm when it came up a bit before seven. I had a bit of tailwind, the roads were clear enough to drive at half speed until the passing cars melted and scattered the snow, and the car was okay for the rest of the trip. By the time I got to Austin, the streets there were  completely clear of snow.

Denny had some chores to finish for Denise, so I checked his wiring while I waited, and I looked over the heavier voltage regulators he had gotten for the power supplies and the three millimeter aluminum plating he had gotten for heatsinks.

When he finished his chores, he got out his drill and router, and we cut the heatsink plates and mounted the voltage regulators and wired up the improved power supplies, and then we checked his board.

It didn't boot, but we found the problem quickly. He had done some soldering late at night and left a solder bridge across a couple of the ROM socket address pins.

Then we looked at the Micro Chroma 68's diagrams and code again, to get as good an idea as possible of what we would be looking for at the surplus shop.

After that, we went out and both crawled under his Fairlane coup, and we spent an hour replacing the transmission, talking about what we would need for the computers while we worked. When we had the replacement tranny installed, we test-drove it around the block. Finally, we cleaned up and drove the car to the surplus shop, for a longer test drive.

Denise was happy to send us on our way, glad to have two cars running again.

John Phillips, the proprietor of the surplus shop, was a former employee at Motorola, and another friend of Denny's.

"Keyboards are all in these bins and on these shelves over here."

"Documentation?"

"What you see is what you get."

None of the keyboards had any documentation.

"I like this keyboard."

"104 keys. Kind of big. Microcontroller controlled."

"That keyboard does not produce ASCII codes," John commented. He didn't have documentation, but he had the necessary information.

"That would require some serious customization, like programming our own controller."

"Guess not. Here's one with no controller at all."

"So we'll have to add a ROM for decoding the keyboard, and patch the monitor ROM to call it. Do you have an EPROM burner?"

"Guess not, not yet. That's something we have to build."

"Yep."

"Hmm. Maybe put some LSI latches and shift registers on a perfboard? Oh. Here's a Cherry."

"Nice. but I was hoping to leave a little money for other things."

"Yeah, Den won't like that price. Here's a 52 key keyboard with some simple LSI."

"I like the layout. But there're no cursor keys."

John commented again, "That one puts out 7 bit ASCII with a negative going strobe. Pretty much like a Cherry keyboard."

"BINGO. Price is good. Do they have two?"

"Yep."

We picked up two and took them to the counter, then went wandering around some more.

"Here's a ten-key pad with cursor keys." I picked it up and showed Denny.

"Do we need it?"

"I think I'll want it."

Denny picked one up and looked it over. "Price is not too steep. Maybe I should get one, too."

"Oh, here Zif sockets for the EPROM programmers we need to make."

 "28 pins?"

I checked. "24, 28, and 40 pin."

"We should be able to do 24 with the 28 pin one. Snag me one."

"I'm going to get the 40 pin socket, too, for programming 68701s."

"Good idea. Get me one, too."

I picked up the sockets.

"Oh Silly scope!"

John laughed.

"Our dad's pun."

"Oh."

"Two hundred dollars is not bad, but I don't have that much. And it only goes to 1 megahertz. We need ten megahertz minimum."

John showed us a couple of hundred megahertz capable scopes, but they were way beyond our financial resources. I wrote the prices down, anyway.

"Reel-to-reel tape drives."

"Cool. Not this time around, though."

"Definitely. Data cassette drive. Ouch. That's too rich, too."

"I can give it to you for half that price."

"Still more than either of us can afford."

"Yeah, and if I had that much, I'd want a floppy drive, instead."

"We have some floppy drives over here." John showed us another set of shelves.

We looked at the drives. "Chassis, motors, screw gear and head assembly, no electronics besides the head."

"Yeah, too much we'd have to develop ourselves, and no tools yet to do it with. Need the scope to align it. But a nice price if we had the tools and the time."

"I'd have the money if I hadn't had to stop at the motel last night."

"That's the best you're going to find, at least this year."

Denny shoved his lower lip to the left in thought. "Dean Brougham has a high speed tape design he was telling me about."

I set my jaw to the right. "I guess it would give us some practice with extracting data, in addition to faster persistent store?"

John nodded. "The encoding and modulation won't be the same, but it would give you something to store programs and data on and share them. I must admit, I'm not sure I'd be able to get one of these to work."

We stopped at the UT campus on the way home, and I picked up catalogs and other materials.

Back at the house, Denny told me to dig out a record to put on the stereo while we worked.

"Deep Purple? Since when were you into hard rock?"

"Thought it was something else. Den kind of likes 'Hush', though."

"No, you do." Denise laughed.

"Heh. Sometimes. But I can't handle listening to the whole album."

"Thinking of the 'Deep Purple Dream' cover by Stevens and Tempo?" I sang a few lines and hummed a few bars.

"That's one I like," Denise gave Denny a significant look.

"But it's not what I was looking for. I thought I bought this for 'Hush'."

"How about Herman's Hermits cover of 'A Kind of Hush'? Or maybe the Carpenters' cover?"

"Dang, that sounds like it might be it."

I sang a few lines of that, too.

"Write those down for me. When we get some extra money, I'll get them for Denise for her birthday or Christmas."

"Promises, promises." Denise smiled wryly, and I quietly promised myself to save up some money for the records.

(In the real world, I couldn't drag the names of either song out of my memory at the time, and it was a long time before I was able to spare any money for music again, even though I had bought some hundred or so albums of various genre before my mission. Before my mission, I would have copied some of my albums to cassette tapes for them. After my mission, I was more careful of copyright. I didn't know about the BASIC interpreter's provenance and copyright status, but I didn't want to use too much of the software that my brother's friends were using without paying for it.)

Over the course of the day, we got the keyboards working and tuned the existing slow cassette circuitry so that we could fairly reliably read program tapes Denny had from his friends, and we could read and write programs and data from each others' boards.

I went to the University of Texas student ward on Sunday, to meet people and see if I liked it.

Before I headed home, we talked about building boxes to mount the Micro Chroma 68 boards in, and I mentioned the sheet-metal lined tea box. Denny grinned and said it would be too big for this project. I had to agree.

And Denny handed me a rail of 64 kilobit RAM chips. "Think you can figure out how to use these?"

"I'll work it out."

When I got home, a letter from Satomi was waiting for me. She informed me she was engaged to a returned missionary I had met on trade-offs, one Brother Fukumasa. I sat down to write a reply congratulating her, and realized I needed to think seriously about going back to Japan.

Chapter 5: Summer Interning

[Backed up at https://joel-rees-economics.blogspot.com/2020/01/bk-33209-micro-chroma-68-lives.html.]
[JMR202001161222: End.]

Monday, January 13, 2020

Backup: 33209: School -- Parameter Stack

[JMR202104051713: Backup of https://joelrees-novels.blogspot.com/2020/01/33209-school-parameter-stack.html.]

Chapter 3.5: School -- BASIC vs. Pascal vs. Assembler

Chapter 3.6: School -- Reference Locality in Software

"I think we should talk a little more about variables and variable names. Remember this?" Professor Crane put the second Pascal version of the shoesz program up on the overhead projector.

program shoesz;

{ Print shoe size table with halves, by Thomas Bright and Rusty Crane }

procedure wrhalf( size: Real );
var
  ipart, numer: Integer;
begin
  ipart := trunc(size);
  numer := trunc((size-ipart+0.25)*2);
  if numer > 1 then
    begin
      numer := 0;
      ipart := ipart+1;
    end;
  write (ipart);
  if numer > 0 then 
    write (' 1/2')
end;

var conv: Char;
  st_sz, end_sz, sz, conv_sz: Real;
  dbl_sz: Integer;

const cm_in = 2.54;

begin
  conv := ' ';
  while (conv<>'E') AND (conv<>'M') do
  begin
    writeln ('Shoe Sizes');
    writeln ('Type E for English to Metric.');
    writeln ('Type M for Metric to English: ');
    readln (conv)
  end;

  writeln ('Start: ');
  readln (st_sz);
  writeln ('End: ');
  readln (end_sz);

  if conv = 'E' then
    writeln ('English => Metric')
  else
    writeln ('Metric => English');

  { Step by halves. }
  for dbl_sz := round(st_sz)*2 to round(end_sz)*2 do 
  begin
    sz := dbl_sz/2.0;
    if conv = 'E' then
      conv_sz := sz*cm_in
    else
      conv_sz := sz/cm_in;
    wrhalf(sz);
    write (chr(9), '=> ');
    wrhalf(conv_sz);
    writeln (chr(9), '(', sz , '=> ', conv_sz, ')')
  end
end.

"That was just what, two days ago?"

"Two classes ago. I think I have my copy here."

Several us dug out our notes from that day.

Professor Crane continued, "What do you think would happen if the size variable, sz, in the main procedure were to be renamed 'size', with the exact same spelling as the parameter size in the write-half routine?"

"Problems?" asked Lisa.

Mike's forehead furrowed in thought as he studied his copy of the source. "Well, you're calling the write-half routine from different places, with different variables. That means the names of the parameters you give it aren't going to conflict with the parameter name in the function."

I studied my own copy. "I think Mike's right. A size variable declared inside of write-half would probably conflict with the size parameter, but Pascal keeps the variable itself on the stack, and it must keep the name of variables local to the half write procedure separate in the dictionary somehow."

Professor Crane rolled his eyes and shook his head, then nodded. "They call that dictionary the symbol table."

Mike turned to give me a sharp look. "Stack?"

George groaned. "What's a stack?"

Pat reached over and poked George in the ribs. "Weren't either of you listening to me the other day?"

Everyone else turned toward Professor Crane. Becky asked, "What are they talking about?"

Professor Crane chuckled. "Something we call locality of reference. In Pascal and certain other languages, variables, constants, and other identifiers are only visible within the block they are declared in, and within blocks declared within the same block."

Pat and I exchanged glances and nods of understanding. Mike, George, and Lisa nodded, hesitantly. The rest of the class just gave him blank looks or shook their heads.

Professor Crane traded the slide for another:

program factfib;

function factorial( number: Integer ): Integer;
  begin
    if number > 0 then
      factorial := number*factorial(number-1)
    else
      factorial := 1;
  end;

function fibonacci( number: Integer ): Integer;
  begin
    if number > 1 then
      fibonacci := fibonacci(number-1)+fibonacci(number-2)
    else 
      fibonacci := number; 
  end;

var number: Integer;

begin
  for number := 0 to 7 do
  writeln( number, ': factorial:', factorial(number),
' fibonacci:', fibonacci(number) ); end.

"What do you think will happen? Will it be able to keep track of all those numbers?"

There were nods and shakes of the head and blank looks.

Andrea said, "I sure can't keep track of them all." 

She and Becky exchanged looks full of doubt.

"What do you think, Pat?" Professor Crane grinned.

Pat nodded. "Sure."

"How about you, Joe?"

"Oh, yeah. No problem. I'm not sure how the symbols are kept local to each scope in the symbol table, but the values are safe on the stack." I started doodling in 68000 assembler again.

"George?"

George scratched his chin. "Wouldn't factorial calling itself overwrite number?"

"Mike?"

"Joe and Pat keep saying something about stacks. Is that something magic where you can stack up the numbers and the compiler somehow keeps track of them all?"

"Very good." Professor Crane swapped slides again. 

"Does that look like a stack of plates to you? How's my artwork?"

There were a few complaints, but mostly hesitant nods. I put my pencil down to focus.

"If you put a plate on the stack, where do you put it? Usually, I mean."

Dirk volunteered, "In the center, especially if it's my mom asking me to."

"I don't know you." Lisa turned her head away and sniffed exaggeratedly.

Dirk snickered.

Professor Crane suppressed a chuckle. "And where do you usually take one off from?" 

Andrea said, "From the top, of course. Why?"

"We can make stacks in programs, using an array and a pointer." He swapped slides again.

"The stack pointer points to the number most recently pushed on the stack. If we pop one off, we read it from where the stack pointer is pointing and decrement the stack pointer. If we push another on, we increment the stack pointer and then store it where the stack pointer points." 

Pat was following along okay, I thought I was, Mike was hanging in there, George was not quite, and the rest of the class were showing various states of confusion. 

Professor Crane showed us a slide with the following demonstration code in BASIC, and walked us through the initialization, the push and pop subroutines, and the execution of the main part:

10 REM PUSH AND POP SUBROUTINES 20 DIM S(10) 30 LET T = -1 REM STACK POINTER 40 LET V0 = -9999 REM TOP OF STACK TEMPORARY 100 V0 = 10 110 GOSUB 1010 120 V0 = 20 130 GOSUB 1010 140 V0 = 30 150 GOSUB 1010 160 V0 = -9999 170 GOSUB 1110 180 PRINT "POPPED "; V0 190 GOSUB 1110 200 PRINT "POPPED "; V0 210 GOSUB 1110 220 PRINT "POPPED "; V0 1000 END 1010 REM PUSH SUBROUTINE 1020 IF T = 10 THEN GOTO 12OO 1030 T = T + 1 1040 S(T) = V0 1050 RETURN 1100 REM 1110 REM POP SUBROUTINE 1120 IF T = -1 THEN GOTO 1300 1130 V0 = S(T) 1140 T = T - 1 1150 RETURN 1200 REM 1210 REM PUSH ERROR 1220 PRINT "STACK FULL ERROR. CAN'T PUSH "; V0; "." 1230 STOP 1300 REM 1310 REM POP ERROR 1320 PRINT "STACK EMPTY ERROR. CAN'T POP." 1330 STOP

Then he showed us a printout of what running it produced:

POPPED  30
POPPED  20
POPPED  10 

We discussed the code for a few minutes, then he showed us demonstration code in Pascal, again walking us through the initialization, pop function, push procedure, and the main execution:

program stackdemo;

const limit = 10;

var

  stack: array[0 .. limit] of Integer;
  tos: Integer;
  errorcode: Integer;

procedure push( value: Integer );
  begin
    if tos < limit then
      begin
        tos := tos + 1;
        stack[ tos ] := value;
      end
    else
      begin
        errorcode := 1;
        writeln( 'Stack full ', errorcode, '. Can''t push ', value, '.' )
      end
  end;

function pop: Integer;
  begin
    if tos >= 0 then
      begin
        pop := stack[ tos ];
        tos := tos - 1;
      end
    else
      begin
        errorcode := 2;
        writeln( 'Stack empty ', errorcode, '. Can''t pop.' );
        pop := -9999
      endfc
  end;
 
begin
  TOS := -1;
  errorcode := 0;
  push( 10 );
  push( 20 );
  push( 30 );
  writeln( 'Popping ', pop );
  writeln( 'Popping ', pop );
  writeln( 'Popping ', pop );
  if errorcode <> 0 then
    writeln( 'errorcode: ', errorcode );
end.

The output was essentially the same as the output of the BASIC demo code:

Popping 30
Popping 20
Popping 10

Becky raised her hand. "Can I see that slide that shows the stack of plates and the, uhm, number stack again?" 

Professor Crane grinned and swapped slides.

Becky thought for a moment, then asked, "Why? uhm, ... in the subroutines, you're only adding one or subtracting one, but the picture of the array shows, what is that? They're all even numbers. That's adding two. Why?"

"Very good." Professor Crane adjusted his slide. "Very observant, Becky. Pat, what do you have to say about this? Joe? Mike?"

The three of us exchanged looks, then Pat nodded to Mike. "What do you think, Mike? You got this?"

He shook his head.

She turned to me, and I lifted my fist, showing gu. "Rock, scissors, paper."

She gave me a quizzical look.

"No jung? Toss a coin, then?" I reached for my pocket.

"You start."

I refrained from pulling out my coin purse. "I'm not sure I can make it make sense."

"Me neither."

I nodded my head in resignation. "Well, okay." I turned to Becky and said, "Address versus index. The picture of the stack array is showing addresses in memory, but the code uses numeric indexes into the array."

Pat nodded. Out of the corner of my eye I saw the light come on in Mike's eyes. 

Becky's eyes reflected something that looked like the beginning of understanding.

Pat asked, "Integers in Pascal are like, two bytes in memory, Professor Crane?" 

"Yep. Well, with the compiler we have, yes."

Becky's eyes lit up, then the flame flickered and was replaced again by doubt. She hesitated, then asked, "So  one in Pascal is like two in assembler or memory or whatever that is?"

"Right!" Mike exclaimed. "Pascal converts the index number to an address. Multiplies the index by the size of the elements and adds the base address of the array." He paused, then continued. "But ... the BASIC array is going to be more than two, right? BASIC variable are floating point, not integers."

Now Becky looked more confused.

Professor Crane nodded in agreement. "Yep. Most BASICS don't have small integer variables. Just floating point, and BASIC floating point numbers tend to be five bytes, as a tradeoff between memory requirements and range."

Becky hesitated again before asking, "So the index would be multiplied by five instead of two?"

Professor Crane smiled and nodded in confirmation.

Becky responded with a proud smile of her own.

After a few more minutes of discussion, Professor Crane looked at me and raised his eyebrows.

"What?"

He grinned. "I thought I saw you doodling a few minutes back.

I glanced at the code I had jotted down before the lesson had gotten interesting. 

"Not really."

He looked disappointed. "So you haven't converted the Fibonacci program to 68000 assembler while we've been discussing how local variables work? Or worked out an assembler version of the stack demonstration code?"

"I got interested in class."

That got a laugh from most of the students.

"Oh."

I scratched behind my ear. "Besides, the stack demonstration wouldn't really be all that interesting."

"Why not?"

"68000 machine language has push and pop built in."

"Built-in, huh?"

"Well, I guess they don't test for overflow or underflow."

"No?"

"I guess the CPU architects leave stack bounds checking to the memory management hardware."

He raised his eyebrows and nodded. "Yes, most CPUs are like that, although I hear Intel's iAPX 432 might be different. So you don't want to show us what the demonstration program would look like in 68000 assembler?"

I set my chin to the right and my mouth the left,  and pinched my nose before scratching my chin. "With no bounds checking?"

"Sure."

"Okay." I stood and went to the whiteboard, and wrote out the following, pausing at moments for thought, but not commenting vocally:

STKSZ EQU 11

SSTACK DS.W STKSZ
PSTACK DS.L 64
RSTACK DS.L 64

MESSAGE DC.B 'Popping '
DC.B 0 ; end of string START MOVE.L #RSTACK+STKSZ*4,A7 ; for return addresses MOVE.L #PSTACK+STKSZ*4,A6 ; for the parameters MOVE.L #SSTACK+STKSZ*2,A5 ; for the demonstration stack * Main code
* Push 16 bit values on 32 bit stack: MOVE.W #10,-(A5) CLR.W -(A6) ; High word first in memory. MOVE.W #20,-(A5) CLR.W -(A6) ; High word MOVE.W #30,-(A5) CLR.W -(A6) ; High word * Pop and print MOVE.L #MESSAGE,-(A6) BSR PSTRING MOVE.L (A5)+,-(A6) BSR PINT BSR PCRLF MOVE.L #MESSAGE,-(A6) BSR PSTRING MOVE.L (A5)+,-(A6) BSR PINT BSR PCRLF MOVE.L #MESSAGE,-(A6) BSR PSTRING MOVE.L (A5)+,-(A6) BSR PINT BSR PCRLF RTS

Professor Crane frowned. "Your stacks are all upside down."

"Most CPU stacks are, aren't they?"

He turned to the class. "Can any of you guys tell what his code does?"

Even Pat was a little bemused. "Can you make it look more like the Pascal and BASIC demonstration code?" she asked.

I grumbled jokingly as I turned back to the board, erased it, and started rewriting, vocalizing both the code and the comments:

* Fully emulating the demonstration stack:
SSTKSZ EQU 11	; Software stack
SSTACK DS.W SSTKSZ	; of 16-bit integers
SSTKPTR DS.W 1	; Don't even need 16 bits.
* Planning on doing it upside-up, with base in A5.

"I could keep the index in D7, too. But I guess we want to see me manipulate the stack pointer as an index, anyway."

ERRORCODE DS.L 1

STKSZ EQU 64
PSTACK DS.L STKSZ ; parameter stack
RSTACK DS.L STKSZ ; return stack
* Both are traditional pushdown.

"Sixty-four levels ought to be enough for whatever the library and OS need."

"Two stacks?" Professor Crane asked.

"I think I like two stacks."

MESSAGE_STR
 DC.B 'Popping '
 DC.B 0

"Not counted strings?" Professor Crane asked.

"Seems easier this way. No compiler to keep track of the count for me, and this way I don't need to keep track by hand."

"Makes sense."

PUSHERRMSG_01
 DC.B 'Stack full. ERROR '
 DC.B 0
PUSHERRMSG_02
 DC.B ': Can''t push '
 DC.B 0
PUSHERRMSG_03
 DC.B '.'
 DC.B 0

I lifted my marker. "Yeah, that's a lot of bits of the message spread out. Oh, well."

"No formatted I/O in the library code?"

"Well, then I would have to explain the library code."

"Ah. Less to explain this way." Professor Crane seemed satisfied.

I continued:

PUSHERR
 MOVE.L #PUSHERRMSG_01,-(A6)
 BSR PSTRING
 MOVE.L ERRORCODE,-(A6)
 BSR PINT
 MOVE.L #PUSHERRMSG_02,-(A6)
 BSR PSTRING
 BSR PINT ; value waiting on parameter stack
 BSR PCRLF
 MOVE.L #PUSHERRMSG_03,-(A6)
 BSR PSTRING
 JMP ERREXIT

"Tedious, but nothing difficult to understand. Put what we want to print on the stack, call the routine to print it."

* Upside-up stack!
* A5 is demonstration stack base.

"Oh, I should probably have put the base in a variable, too. But I'm doing it this way, now." 

"Let's see how it turns out."

PUSH
 MOVE.W SSTKPTR,D7
 CMP.W #STKSZ,D7
 BHS PUSHERR ; unsigned

"That loads the stack pointer, and then compares it to the size of the stack. By using an unsigned compare, we can skip testing the lower bound of zero. But the Pascal source didn't check the opposite end, anyway."

"True."

 ADD.W #1,D7
 MOVE.W D7,SSTKPTR ; update pointer
 ASL.W #1,D7 ; adjust index for 16-bit array

"Arithmetic shifting left is the same as multiplying by two." 

Professor Crane added, "Becky, there's your conversion between index and offset to an address." 

"Oh-kay." But she didn't really sound all that okay, yet.

 MOVE.L (A6)+,D0 ; pop 32 bits of parameter

"A6 in paranthesis says A6 points to the source value. The plus after says that the CPU updates the pointer after the move, by adding the size of what it moved to D0. The parameter stack that A6 points to is 32 bits wide, to save code. That's four bytes, so A6 gets four added to it."

 MOVE.W D0,(A5,D7.W) ; store 16-bit integer

"The value stored was only our 16-bit integer, so we only need to store two bytes. And that funky looking index expression in the parenthesis here says that A6 has the base address of the array, and D7 has the offset -- the index we multiplied by two up there. The CPU adds the base and the offset to get the address of the element of the array to store it in."

Becky hesitated before saying, "A6 plus D7 is the address where it's stored?"

"Yeah." 

"What's that period double-u mean?"

"W stands for word, and a 16-bit integer in 68000 assembler is called a word. An 8-bit integer is B for byte, and a 32-bit integer is L for long."

"Hmm. Maybe I'm seeing this."

"Great."

 RTS

"The return from subroutine instruction pops the return address from the return stack and loads it into the program counter, which is what Motorola calls the instruction pointer. And the pop routine just reverses this process."

POPERRMSG_01
 DC.B 'Stack empty. ERROR '
 DC.B 0

"Can't tell anyone about a value that doesn't exist."

POPERRMSG_02
 DC.B ': Can''t pop.'
 DC.B 0
*
POPERR
 MOVE.L #POPERRMSG_01,-(A6)
 BSR PSTRING
 MOVE.L ERRORCODE,-(A6)
 BSR PINT
 MOVE.L #POPERRMSG_02,-(A6)
 BSR PSTRING
 BSR PCRLF
 JMP ERREXIT
*
POP
 MOVE.W SSTKPTR,D7 ; Not testing for too high.

"On the 68000, loading a data register sets the condition codes, so we already know if it's zero or minus. Minus would be a stack underflow. And will ignore testing against the other end of the stack here."

 BMI POPERR
 ASL.W #1,D7 ; adjust index for 16-bit array
 MOVE.W (A5,D7.W),D0
EXT.L D0 ; Make it 32-bit

"We'll extend the sign bit, since we'll be passing it to library functions."

 MOVE.L D0,-(A6)
 SUB.W #1,SSTKPTR ; update pointer

"Conveniently, the 68000 allows us to add that one to the index in memory, so we don't have to keep an extra copy in a register." 

"Like you don't have enough extra registers to keep a copy," Professor Crane joked.

"Heh."

 RTS

START
* Runtime.

"First, we set up the return stack pointer so we can do subroutine calls, and the parameter stack pointer so we can pass parameters."

 MOVE.L #RSTACK+STKSZ*4,A7 ; for return addresses
 MOVE.L #PSTACK+STKSZ*4,A6 ; for the parameters 

"Wait a minute." Professor Crane stopped me.

"Yeah?"

"Oh, yeah, you said you like two stacks."

"I think so."

"Does the 68000 have instructions to support stack frames?"

"There's a link instruction and an unlink instruction."

"Hmm. Go ahead."
 MOVE.L #SSTACK,A5 ; emulating the demonstration stack
 MOVE.L #0,SSTKPTR ; demonstration stack index

Becky muttered, "Okay, there's the base of that array, and the index." 

I nodded and continued writing:

* Main code:
* push values
 MOVE.W #10,-(A6)
 CLR.W -(A6) ; High word first in memory.

"Woops. That should also be sign-extended." I thought for a minute, erased the last line, and changed the line before it:

 MOVE.L #10,-(A6)

Pat asked, "The 68000 is most significant bit first?" 

"Yeah."

"Isn't that inefficient?"

"Ask the engineers. It sure seems easier for human eyes to read." 

I have much stronger arguments about byte order now, but we don't want to interrupt the story too much.

 BSR PUSH
 MOVE.L #20,-(A6)
 BSR PUSH
 MOVE.L #30,-(A6)
 BSR PUSH
* Pop and print
 MOVE.L #MESSAGE,-(A6)
 BSR PSTRING
 BSR POP
 BSR PINT
 BSR PCRLF
 MOVE.L #MESSAGE,-(A6)
 BSR PSTRING
 BSR POP
 BSR PINT
 BSR PCRLF
 MOVE.L #MESSAGE,-(A6)
 BSR PSTRING
 BSR POP
 BSR PINT
 BSR PCRLF
 RTS 

When I turned around,  only Daren, Andrea, and Alex still looked lost.

"So, how would that change if you used stack frames?" Professor Crane's eyebrows were raised.

"On a single stack?"

"Most system engineers don't want to go to the trouble of supporting two stacks."

"I sure don't know why. But with something this simple, there really isn't a reason for frames at all."

"That might make it easier to understand the frames."

 "Maybe. But I don't think I remember exactly what the link and unlink instructions do. How about if I just show where we can save a stack frame pointer in this code?"

"You can?"

"Pretty simple, really. On routine entry, you just push a copy of the parameter stack pointer, probably on the return stack to keep the parameter stack clean and give the frame pointer some protection. Then just remember to pop it on exit."

I wrote a fragment on the board:

SUBROUTINEA
 MOVE.L A6,-(A7) ; Mark frame.
 ...
 MOVE.L (A7)+,A6 ; Force restore frame.
 RTS 

Or, since the parameter stack is balanced, instead of loading the parameter stack pointer back, just  drop the saved frame pointer off the return stack:"

SUBROUTINEA
 MOVE.L A6,-(A7) ; Mark frame.
 ...
 ADD.L #4,A7 ; Drop frame.
 RTS 
"Either way, you can load the frame pointer from the return stack whenever you need it."

"How do you tell the parameters of a recursive call from those of a non-recursive call?"

I had to think for a moment. "Maybe you have to mark the frame before you call the subroutine. Then, I guess, when a routine calls itself recursively, it would do something else:"

ROUTINEA
... MOVE.L A6,-(A7) ; Mark frame.
BSR RECROUTINE ADD.L #4,A7 ; Drop frame.
... RTS
*
RECROUTINE
...
MOVE.L 4(A7),A4 ; Saved PC is top. MOVE.L A4,-(A7) ; Mark old frame.
BSR RECROUTINE ADD.L #4,A7 ; Drop frame.
... RTS

 Professor Crane looked at my code with a puzzled expression. "That looks like it might work, actually."

The bell rang.

"Okay, we'll continue this next class. Homework is to write the Fibonacci series code recursively in BASIC."

Groans echoed through the room.

"And, Joe, can you look up the link and unlink instructions and bring some code using them?"

"Sure."

Chapter 3.7: 
TOC

[Current backup at https://joel-rees-economics.blogspot.com/2020/01/bk-33209-school-parameter-stack.html.
Developed February to April 2021, notes at https://joel-rees-economics.blogspot.com/2020/01/notes-33209-school-basic-vs-pascal-vs.html.
Extracted and expanded from https://joel-rees-economics.blogspot.com/2020/01/bk01-33209-school.html.
Earlier backup at https://joel-rees-economics.blogspot.com/2020/01/bk-33209-school.html.]

Backup: 33209: School -- BASIC vs. Pascal vs. Assembler

[JMRbefore20210330.]Backup of https://joelrees-novels.blogspot.com/2020/01/33209-school-basic-vs-pascal-vs-assembler.html.

Chapter 3.4: School -- Shoe Sizes, Flowcharting, and Pseudo-code

Chapter 3.5: School -- BASIC vs. Pascal vs. Assembler

Professor Crane set aside the slides he had been using to explain the simple address book program that would be our next assignment and picked up another set. 

"I'm sure y'all all want to talk about Pascal some more."

Scattered chuckles and groans greeted the pronouncement.

"Well, we're going to talk a little more about Pascal today so we can talk about something Professor Bright and I are studying, called structured programming." He paused.

"There are dialects of BASIC in existence which don't use line numbers. And you can write programs in those without using a GOTO."

"Cool."

"Wow!"

"Help?"

"Why not just move to Pascal instead of ruining BASIC?"

I was not one who said any of the above. I think my response was, "So, these versions of BASIC look kind of like Pascal?"

"Kind of."

"How does that even work?" asked Becky.

"Well, let's talk about structured programming." He waited for the chatter to stop. "In BASIC, you can write code that looks like a plate of logical spaghetti with strands of program flow going all over the place and getting all tangled up in a mess. In Pascal, it's a lot harder to write spaghetti code. But even in BASIC, you can usually untangle that spaghetti into more understandable sequences of just a few kinds of fundamental elements." He put a slide on the overhead projector.


"This is one fundamental element, the block. And on the right is a sequence of blocks."

Lisa asked, "Is a block like a line of BASIC?"

"Or of Pascal. A line or a group or lines can be a block. The idea is that together they perform a single function. And you can treat them like a single block. Ideally, you start in at the top of the block and end at the bottom. Pascal also allows you to explicitly declare a block using the BEGIN and END statements."

He waited for a moment so we could copy the slide into our notes. Then he traded the slide for another.

"This is the decision, conditional, or branch."

"It's the BASIC IF statement," asserted Daren.

"Very good. It gets constructed with the IF statement, and often requires GOTOs in the usual dialects of BASIC. The GOTO will jump around the false and true blocks for he the condition George, can you write us an example on the board?"

George went to the board and wrote:

1000 REM TWO-WAY DECISION
1010 IF V1 = V2 THEN GOTO 1100
1020 REM FALSE BRANCH
1030 A1=B1
1040 REM ETC.
1090 GOTO 1200
1100 REM TRUE BRANCH
1110 B1=A1
1120 REM ETC.
1190 REM END OF BLOCK
1200 REM SOMETHING ELSE CONTINUES FROM HERE.

Instead of copying what he wrote, I doodled on the back of a program listing:

* 2-way decision/branch (conditional)
* IF V1 = V2, 32-bit integer V1 and V2
	MOVE.L vV1,D0
 	SUB.L  vV2,D0
 	BNE IFNEV1V2  ; Inverted test.
* LET A1 = B1
MOVE.L vA1,vB1 ; true branch * etc. BRA IFDONEV1V2 IFNEV1V2 ; false branch * LET B1 = A1 MOVE.L vB1,vA1 * etc. * end of block IFDONEV1V2 * continues from here

Several of the students were still busily taking notes when George sat down. 

Professor Crane asked for questions, but the students who were lost just gave him blank looks. So he continued, "In Pascal, that would look like this." He took out a clean slide and put it on the projector, and wrote:

{ Two-way decision }
  IF V1 = V2 THEN 
  BEGIN
    { True branch! }
    B1 := A1
    { Etc. }
  END
  ELSE
  BEGIN
    { False branch. }
    A1 := B1
    { Etc. }
  END
  { Something else continues from here. }

"Why do I have the false and true branches reversed here from the BASIC code?"

Lisa suggested, "Because the test will make a jump, and you jump to the true branch, but, uhmm," she thought, then continued slowly, "... just let the program flow into the false branch?"

Becky exclaimed, "Oh, I get it." She hesitated. "I think."

"Good. Anyone not getting it?"

No response.

Professor Crane stood up and walked around the room, checking students' notes. He stopped at my desk. "May I?"

I looked up at him questioningly. 

"Take a look at your assembler notes. Is this 68000 assembler?"

"Yeah. I didn't want to think too hard about integer size." I held the page up, and he accepted it.

"Mind putting this up on the board to show the class?"

"Sure. I mean, no. No problem." I stood and went to the board, repeating the doodled code from memory.

Professor Crane pointed to the first line. "Is this a comment?"

"Yeah. Comment lines start with asterisk in Motorola assemblers."

"Interesting." He pointed to the third line. "Move dot 'L'?"

"Long is 32 bits. Dot 'W' would be word, or sixteen bits. Dot 'B' would be byte, or eight bits."

"So that's a 32-bit integer move. 8086 only does 16-bit. You put 'v' in front of the variable names?"

"Otherwise, A1 would, uhm, the name of variable A1 would conflict with the name of address register A1."

"I see. Okay, Intel syntax has the target first, as move to target from source. I guess Motorola syntax is more English-like, move from source to target?"

"Yeah. Data register zero is the target of the first move. I'm using subtract for the compare in the next line because," I hesitated here, "the compare is just a subtract that doesn't store it's result, and I'm pretty sure it's the same order as subtract, but I didn't want to think about it. Not that it matters here, since we're only testing equality."

Professor Crane snorted a chuckle and shook his head. "How many registers does the 68000 have?"

"Eight data registers, D0 through D7, and eight address registers, A0 through A7. Ehh, plus a second A7. A7 is the stack pointer for subroutine calls, and there's a user A7 and a system A7." 

"That's a lot of registers. Does it have an accumulator?"

"Any data register can be an accumulator."

He raised his eyebrows and turned back to the listing. "Okay, 'BNE' is?"

"Branch if not equal. Not equal to zero. Inverted condition so I could write the true branch first. Branch to," I spelled it out: "'I-F-N-E-V-1-V-2'. That label is supposed to mean 'If not equal V1 and V2'."

"You made the label up."

"Yep." 

"And labels are?"

"Machine language has addresses instead of line numbers, but when you edit code, the code moves around, so the addresses change. So the assembler lets you give a location a name, and then the assembler figures out the address for you."

"So it's like a line number, but different."

"Right."

"Okay. Is that a memory-to-memory move in the next instruction, direct, without using a register?"

"Yeah. Target is the second argument."

"Again, opposite Intel assembler order. And that is not a reference to women's underwear in the next instruction?"

There was a wave of snickers and titters.

"Branch always," I answered apologetically. "I think I would have just used 'BR' or written it out 'BRANCH', but I'm not the one who made up the mnemonics."

Professor Crane nodded. "I hope none of the women in the class are offended. Macros would allow that instruction to be renamed, by the way."

Lisa cleared her throat. "How nice of them." She and Pat exchanged looks.

Pat shrugged. "I wish we didn't have to put up with immature male engineers. It sure isn't an ideal world."

Dirk let out a horse laugh. "Yer im-mah-choor, Joe."

Lisa gave him a glare. 

"Okay, okay, maybe I'm a little immature, too, sometimes." Dirk was still laughing, but not out loud. "How about you, Joe?"

I rolled my eyes and shrugged. "Probably not as mature as I ought to be all the time."

"So we'll both try to grow up?" He grinned at me.

"Yeah."

Lisa sniffed and turned away. Since she was between Dirk and me, she was now looking at me. She tried to keep a straight face, then broke out laughing when I shrugged apologetically again. She looked back to Pat and said, "We're holding these guys to their promise, right?" 

Pat nodded, her face showing mixed feelings.

"We'll work on it." I reached over and bumped fists with Dirk.

"Is one- or two-way branching all there is in structured programming?" Mike asked.

Professor took the cue. "There is also a case construct, but it can be built from these two. We can look at it later. I want us to look at loops now." 

"Wait," Becky hold up her hand. "Don't you need more branches to surround the false and true blocks?"

I turned back to the whiteboard and pointed to the code between the branch not equal and the branch always. "Since the test is inverted, the false case branches over the true case block." I pointed to the branch always. "The true case ends by branching over the false case block to the label 'IFDONEV1V2'. But, since that label is just the address of the instruction after the false case block, the program flow naturally joins back together there without a branch."

Becky still looked a little puzzled, but she nodded.

I sat down.

Professor Crane had swapped slides while we were discussing the program flow.

"Here we are. These are the two loops generally discussed in structured programing."

Mike asked, "Is there a mid-test loop?"

Professor Crane pulled his mouth to the side.

I looked up and added, "As in a general loop with a block before and after the test?"

Mike glanced at me and nodded. 

Professor Crane still hesitated.

Mike stood. "Can I draw out what I mean?"

"Go for it." Professor Crane held out a marker.

Mike took it and drew this:

Professor Crane nodded thoughtfully. "That's a general loop. There are languages that have such loops built-in, but most structured programming practice suggests against it, from what I understand. Pascal doesn't have one."

Mike turned back to the board and wrote out example BASIC code for the loop to the side:

2000 REM LOOP STARTS HERE
2010 REM PRE-TEST BLOCK
2020 A=B+C
2030 REM ETC.
2100 IF A=E THEN GOTO 2200
2110 REM POST-TEST BLOCK
2120 A=-B-C
2130 REM ETC.
2190 GOTO 2000
2200 REM PROGRAM CONTINUES FROM HERE

"And the pre-test and post-test loops would just have one of those blocks empty," he commented as he put the marker back in the tray.

Alex complained, "What does that code even do?"

Mike frowned and cocked his head. "It's just example code."

"Just enough," I looked up from my assembly language doodling, "to see the connection between the BASIC and the flowchart." 

I had this scribbled down at this point:

LOOPSTART
* Pre-test block
* A=B+C
MOVE.L vB,D0
ADD.L vC,D0
MOVE.L D0,vA
* Etc.
* IF A=E THEN GOTO exit
CMP.L vE,D0 ; D0 - vE
BEQ LOOPEND
* Post-test block
* A=-B-C
CLR.L D0
SUB.L vB,D0
SUB.L vC,D0
MOVE.L D0,vA
* Etc.
LOOPEND 

Mike frowned and turned back to the whiteboard. He picked up the eraser, but Professor Crane said, "We have lots of whiteboard space."

So he put the eraser down and started writing more code in an open spot:

2000 REM GET NEXT SHOE SIZE
2010 INPUT "SHOE SIZE ('Q' FOR QUIT):"; R$
2020 IF LEFT$(1) = "Q" THEN GOTO 2200
2030 R = VAL( R$)
2040 REM ...
2200 GOTO 2000

"That is a more real example. After we talk a bit more about the basics, I can show you how that's done with a conditional inside a post-test loop." Professor Crane swapped slides on the projector again and proceeded to use the remainder of the period to lead the class through comparing the structured flow elements in Pascal, BASIC, and, borrowing more of my doodling, assembly language. Our assignment was a simple address book program using BASIC DATA statements to build separate arrays of names, addresses, and phone numbers.

(Maybe I don't need to say this again, but I will. The Joe of this novel is way ahead of the Joe of the real world. I had only begun to pick up the rudiments of 6800 assembler during the first semester back from my mission. Translating BASIC or Pascal to 68000 assembler during a lecture would have been me at least a year later, probably two. 

And I wasn't that good with banter. Still not, really.)

TOC

[Current backup at https://joel-rees-economics.blogspot.com/2020/01/bk-33209-school-basic-vs-pascal-vs-assembler.html.
Developed February and March 2021, notes at https://joel-rees-economics.blogspot.com/2020/01/notes-33209-school-basic-vs-pascal-vs.html.
Extracted and expanded from https://joel-rees-economics.blogspot.com/2020/01/bk01-33209-school.html.
Earlier backup at https://joel-rees-economics.blogspot.com/2020/01/bk-33209-school.html.]

Backup: 33209: School -- Shoe Sizes, Flowcharting, and Pseudo-code

Backup of https://joelrees-novels.blogspot.com/2020/01/33209-school-shoe-sizes-flowcharting-and-pseudo-code.html.

Chapter 3.3: School -- Shoe Sizes and Pascal

Chapter 3.4: School -- Shoe Sizes, Flowcharting, and Psuedo-code

Back in the classroom, Professor Crane passed out copies of the simple version of the BASIC program.

"Mmm. Fresh Ditto. Smells good!" Dirk sniffed the paper.

"Is ditto fluid addicting?" Lisa asked no one in particular.

"Spirit duplicator fluid could be addictive and intoxicating if you do too much copying in a closed space, but I don't think there's enough left on these pages to do any real damage." I picked my page up and sniffed.

"Thank you for your analysis, Mr. Genius." Lisa grinned to show she was just teasing.

I ducked my head and grinned back.

"Okay, let's look at this and turn it into a flowchart." Professor Crane picked up a marker from the whiteboard tray. "Becky, you wanna do the artwork today?" 

(This was a different Becky from the student who had accompanied me on the piano at the first recital.)

"Uhm, okay." Becky stood up hesitatingly and went to the front of the room. 

Professor Crane handed her the marker, and she stood, waiting.

"What's the first thing we do here?" Professor Crane looked around at the students. "Theo?"

"Print the program title?" Theo responded.

"Okay."

Becky turned to the board and started drawing.

After about five minutes, we had produced the following flowchart as a class:

"What do we have to change on this flowchart if we use the second program?" Professor Crane asked.

George raised his hand. "Print converted size becomes a subroutine call, is all, isn't it?"

"Becky? What do ya think?"

Becky nodded. "So I add double side lines to the print converted size box like this?" She added the lines in the way our classes were being instructed to indicate subroutine calls.

"And then we add a short flowchart to show what that does," Mike pointed out.

It took another five minutes of discussion to produce the following flowchart of the subroutine:

"Is everyone pretty comfortable with these flowcharts?" Professor Crane looked around the class again.

Alex raised her hand. "Should we expand other parts?"

I responded, "Depends on how much detail you want in the flowchart, right?"

Professor Crane nodded. "That brings up something I need to explain. I mentioned before, I think, that different people use different symbols in flowcharts."

We all agreed.

"Some people use the parallel lines to merely mean that there is a logical module there. It might be a subroutine call or it might be something called a macro, which I'll have to explain sometime, or it might be many lines of code that they want to describe as a single functional block."

Mike responded, "You said that before."

"I did. Well, there is a symbol you might want to use to show this is really a subroutine call. Becky, may I?" He held out his hand, and Becky gave him the marker. 

"Thank you. You can take a break now."

Becky grinned a "Yay!" and sat down.

"It looks sort of like a punched card." He drew the following on an empty spot on the board:

I think most of us took that down in our notes somewhere. I just adjusted my flowchart.

Pat asked, "I've been using macros at work. I'm not really sure what they are."

"Mmm," Professor Crane looked at the clock. "I want to talk about pseudo-code before we break up for today. Can we do that tomorrow?"

"Yeah, I guess."

Professor Crane turned on the overhead projector, directed the projected image to the side of the flowchart, and took out a slide and a marker. "Pseudo-code is something like a programming language and something like natural language." He looked around at us. "Like English." He wrote: 

Shoe Size Conversion Table 

Show title.

Get conversion direction.

Get start and end. 

For shoe sizes from start to end,

print conversion line,

George  commented, "You're almost just copying the contents of the flowchart and making it more like English." 

"Pretty much. As you see, it uses indentation something like the Pascal source code we just saw a little bit ago, but it's a bit freer in form and allows more descriptive. It's often fairly easy to convert a clean flowchart to pseudo-code, or back-and-forth between pseudo-code and a language like Pascal. Some people find pseudo-code easier to use than flowcharts."

"Are you going to expand every line of that?" I asked.

"That depends on you, and on the group you're working for. For some groups, any further conversion of the above should be directly to code. For others, more detail is wanted."

Mike asked, "If 'print-conversion-line' is the name of the subroutine, you could pseudo-code the subroutine, right?"

"You and Joe," Professor Crane grumbled jokingly. "Exactly right." And he proceeded to do so:

Print conversion line

Take integer part of converted size.

Take fractional part.

If fractional part is 3/4 or more, 

increment integer part and clear fractional part;

else if fractional part is less than 1/4,

clear fractional part.

Print integer part.

If fractional part is non-zero, 

print "1/2".

He handed out ditto copies of the Pascal source code for us to compare.

I looked over at Pat, and she looked up at me. 

"Maybe macros are just some way to pull the actual source code in-line into the program instead of calling it like a subroutine?" I suggested. 

She looked puzzled.

"I've seen them mentioned in the microprocessor documentation my brother gave me, and the assembly listings actually show the macro lines as if they were part of the source."

"That might make sense."

I looked up and noticed Professor Crane standing beside my desk. 

He was shaking his head. "Maybe I should just let you and Mike take over for me, and I'll just kick back and put my feet up in the back of the room."

"Sorry."

"No problem." He grinned broadly. "You really don't need a copy of the Pascal, do you?"

He handed me my copy.

"Yeah, thanks. I think I need it." I grinned back.

The bell rang.

He announced from where he was, "We'll talk more about pseudo-code, Pascal, and macros next time. In the meantime, I want to see the flowcharts you've each drawn up, and I want you to try writing a quick program in BASIC to let the user type in a conversion direction and a shoe size, and print out the conversion. It should be easy, and it'll let me see whether you were listening today. Turn your listings and flowcharts in at my office."

The class broke up with the usual grumbling and jesting.

TOC

[Current backup at https://joel-rees-economics.blogspot.com/2020/01/bk-33209-school-shoe-sizes-flowcharting-and-pseudo-code.html.
Developed February and March 2021, notes at https://joel-rees-economics.blogspot.com/2020/01/notes-33209-school-basic-vs-pascal-vs.html.
Extracted and expanded from https://joel-rees-economics.blogspot.com/2020/01/bk01-33209-school.html.
Earlier backup at https://joel-rees-economics.blogspot.com/2020/01/bk-33209-school.html.]