Only because I could...

I managed to write an algorithm that would perform 16-bit long division using just the ADD, AND and NOT operators of the LC-3 machine simulator.

Just to make sure everyone understands, I am teaching an assembly language class at UVU and the class uses the LC-3 machine simulator. It's nice, but it has a grand total of three arithmetic operators: ADD, AND and NOT. Subtraction is done by performing a 2s complement inversion on the number being subtracted, then performing addition. Division could be performed by counting the number of subtractions of the denominator from the numerator, but this method scales horribly. Long division would be nice, but you probably noticed the lack of a bitwise shift operator in my list of arithmetic operators.

This stymied me for a while, until last night when I was reminded that left-shifting bits will multiply a number by two, thus adding a number to itself is a fine simulation of the left-shift operator. This is actually so stinking obvious that I feel the need for penance for my obvious act of slothfulness.

So, here's what I did. One LC3 register was maintained for the original numerator and would be rotated through the range of 16-bits. Another register would maintain a bitmask to allow only the bits that had been rotated. This would allow me to subtract the denominator from only the rotated bits. For every successful positive subtraction I would shift in a bit the last register - the quotient. When the bitmask became negative (the high-bit was set), then I was done.

Again, obvious. Here's the code I wrote in about 30 minutes at 11:00pm last night:

	NOT	R3, R1
	ADD	R3, R3, #1	; R3 will be the subtracting denominator
	ADD	R1, R0, #0	; R1 will be the rotated numerator
	AND	R0, R0, #0	; R0 will be the advancing quotient
	AND	R2, R2, #0	; R2 will be the numerator bitmask
DIVROLL	ADD	R2, R2, #0	; First, are we done?  Test if the bitmask is negative
	ADD	R2, R2, R2	; Shift mask left and add one
	ADD	R2, R2, #1
	ADD	R0, R0, R0	; Shift the quotient left
	ADD	R4, R1, R1	; Roll numerator
	ADD	R1, R1, #0
	ADD	R4, R4, #1	; Roll the high bit into the low
	AND	R4, R1, R2	; Mask
	ADD	R4, R4, R3	; Test
	ADD	R1, R1, R3	; Subtract from numerator and set a bit in the quotient
	ADD	R0, R0, #1
	BRnzp DIVROLL		; And do it again

Special thanks to Yale Patt of The University of Texas at Austin for providing me the information for my "Oh Duh" moment (it's in hint#2).

Windows XP Update Kills

Have I told you recently how much I love Linux and all the GNU utilities that surround it?

Sunday I was asked to help out a family in need. Their computer would no longer work and I was politely asked if I would be willing to get the machine back on it's feet. In my opinion, there's nothing better to do than use what little talent I have to help those in need. I certainly wouldn't be much help if they asked me to replace a head gasket for them.

The machine was brought to me and after a quick check it was obvious that one or more key files for the OS were gone. Specifically vgaoem.fon was not available, which tells me that something chewed-up and spit-out the system - probably a worm or virus. Fortunately for the owner of this machine, it is an HP and it still had it's original recovery partition. After a few click and a restore, the system booted and was ready for me to bring it up to date.

Now, I said that last sentence easily, with little stress. I have become use to an update process that rarely requires a full system reboot, and that only when the core system kernel has been replaced. There rapidly comes a time when even that might not be necessary with kexec and all. Updates are pleasant experiences that take a little time but bring fresh, clean software.

I had forgotten about the Windows update process.

Please understand that this is a rather old machine. It's running a Pentium 4 with 512Meg of memory. Not the beefiest machine, and certainly will be somewhat slow - but it'll work. Right?

I started updating at about 6:00 pm. This system appeared to be at WinXP SP1, but the first thing it needed to do was update it's updating software - and reboot. OK, I don't understand why a simple program (it's simple, right?) needs a reboot, but I'll go with it.

Next it needed to install SP2. This was about the time when I started remembering just how painful this process could be. This is about 6:45pm and roughly the time I decided to take a nice walk with my family. I needed to find my happy-place, and soon.

When I got back, the SP2 update needed rebooting. Then followed the patches to SP2, then followed the SP3 update, then followed more patches to the SP3 update, then followed a patch to the previous patch. Each of these updates required a new reboot. Mind you, the reboot was the fast part of the patching process. Overall, each patch took one to two hours.

Then I was silly enough to attempt the optional upgrades. Oh, what was I thinking?! Even still, after a three hour software upgrade (media player and various collaboration tools), it failed. The error I got told me I was canceling the install. Lies!

Anyway, at about 3:30am, Lisa comes out to tell me that I'm an idiot that needs to be getting up in two hours. OK, she didn't directly call me an idiot (she's too nice for that), but it was pretty obvious to me what appellation should be applied. Luckily for my sleep schedule, I managed to nap in between updates starting at midnight. I may not completely die today.

Anyway, I write this post in order to help me remember how bad the update process is, and to schedule a couple of days in order to cover the madness. Someday I may learn.

2009/10/19 07:08 · John L. Jolly · 1 Comment · 0 Linkbacks

T-Mobile doesn't want my money

Y'know, I live in a wonderful world full of technological possibilities. A global communications network exists that allows me to communicate to almost anyone, almost anywhere. I can sit at my computer and write something that the entire world could (if they cared, of course) read the moment I finished writing. Nearly all of this is driven by money-hungry corporate interests. These guys can virtually conquer the world as long as it makes them a little more money.

Except for T-Mobile, that is. They apparently want their customers to move to other carriers.

Early this year I bought a T-Mobile prepaid mobile phone for my second son. He was beginning to need his own phone, especially during the adverse winter weather we had experienced. I thought I would try a prepaid phone this once to see if it was worthwhile. In order to get a good idea what it's total cost would be, I put $100 onto the phone and handed it over to the boy.

September rolled around and he informed me that the phone was running dry of available minutes. I had given him the phone without informing him it was a prepaid, so that he would give it “normal” usage. Considering he probably was not consistent in his usage - he likely used it less at the beginning than he did at the end - he might have run out earlier than the 9 months he experienced. This means he spent a little over $10 a month communicating with people.

Here's the rub. If that phone had been tied to my T-Mobile account, he would have only been $10 a month plus taxes, or a little over. There didn't seem to be any reason to keep his phone off our account, so I contacted T-Mobile to see if I could get his number moved over.

T-Mobile said no.

Now, the prepaid service is with T-Mobile as well, which seems to be the problem. T-Mobile prepaid phone numbers cannot be transferred to a T-Mobile account. To someone like me - where it's a simple matter of programming the correct logic to move numbers from one database to another - this seemed worse than inconvenient, it was stupid bureaucratic silliness. Someone on high made a decision not to interoperate, which could only be made by an ignorant body in a suit.

Well, as I am never one to accept policy-based inanities, I decided to call AT&T. Guess what, they're happy to take my mon … ahh, transfer my number. Verizon even tells me the number is portable. So now what is going to stop me from moving this line, along with all my other lines, to another carrier? This is not the way to keep a customer.

This goes along with an experience I had in July with T-Mobile. Seems if you want a discount on a phone, you need to wait until your contract completely expires before they will give you that discount. I stated to the T-Mobile representative at the time that this goes against any marketing common sense that I've ever experienced. Drug dealers don't refuse to sell to junkies until after they've recovered. Mobile phone companies should be trying to reel their current customers in before their contract has expired. Wait until there's no penalty to move to another company, and I will likely jump ship.

My biggest regret is that I was looking forward to renewing with T-Mobile in May. I really want to get one of those MyTouch phones to play with. Now I'm looking to unite all my lines under any plan *other* than T-Mobile. Perhaps I will end up getting an Apple iPhone.

Thanks T-Mobile for keeping my options open for me.

Tyler's Weber March up on YouTube

I just posted the video taken by Lisa of The Spanish Fork High School Marching Band performance at Weber State University. I am far from musically proficient, so all I can say is that they seem to do pretty well, with a couple of glitches here and there. I like the choreography of the show, though. Their sneaky bit at the first is fun to watch in person. Kudos to my lovely spouse for a nice recording job.

I've always been amazed that I have two boys that are pretty good at the music. I've never been that much of a music performer. Back when Candy was my step-mom, I vaguely remember practicing the piano, or rather not practicing the piano while I was getting yelled at for amounting to nothing. I have many regrets about my childhood, but that one probably stands out the most. I still wish I could play, and occasionally peck at the piano that sits next to me nearly all day, but to no lasting usefulness. I need to work on my physical fitness before I can spend time learning to play an instrument, though.

Enough whimpering. I'm very happy that my two oldest boys have become proficient in the instruments of their choice. Tyler is quite the drummer, and his dedication is admirable. Aaron is amazing at the Cello, and I am highly impressed at how he challenges himself without any coaxing from his parents. They're both good kids and I'm very happy to be their father.

Starting Fresh

Here I go again. This time, I only blog what I'm up to, and provide links to the content. This was my set-up-DocuWiki experience, and it wasn't too bad. I've decided to add blogging to the site, as well as normal wiki, just so I can have a way to document my activities.

The big deal here is that I am opening up the wiki to anyone named John Jolly. It has been altogether too selfish of me, hogging this domain name all to myself. Now if your name is John Jolly, you can create content under your domain name. I'm not charging or putting up ads or anything. Send me an email and I'll get you an account.

So there you have it, I'll start writing regularly and I'll try not to pollute my blog with too much technical babble.


2009/09/21 11:04 · John L. Jolly · 0 Comments · 0 Linkbacks

<< Newer entries

You could leave a comment if you were logged in.


navigation [The John Jolly Wiki] , 2009/09/23 07:11 (Pingback)
[...] His Blog [...]