Mel's Loop
A Comprehensive Guide to The Story of Mel

The Story of Mel

This was posted to Usenet by its author, Ed Nather <>, on May 21, 1983:

A recent article devoted to the macho side of programmingmade the bold and unvarnished statement:

write in .

Maybe they do now,in this decadent era ofLite beer, hand calculators, and "user-friendly" softwarebut back in the Good Old Days,when the term "software" sounded funnyand Real Computers were made out of and , wrote in .Not . Not . Not, even, ..Raw, unadorned, inscrutable numbers.Directly.

Lest a whole new generation of programmersgrow up in ignorance of this glorious past,I feel duty-bound to describe,as best I can through the generation gap,how a wrote code.I'll call him Mel,because that was his name.

I first met Mel when I went to work for Royal McBee Computer Corp.,a now-defunct subsidiary of the typewriter company.The firm manufactured the ,a small, cheap (by the standards of the day) computer,and had just started to manufacturethe , a much-improved,bigger, better, faster — computer. cost too much,and weren't here to stay, anyway.(That's why you haven't heard of the company,or the computer.)

I had been hired to write a for this new marvel and Mel was my guide to its wonders.Mel didn't approve of .

"If a program can't rewrite its own code",he asked, "what good is it?"

Mel had written,in ,the most popular computer program the company owned.It ran on the and played blackjack with potential customersat computer shows.Its effect was always dramatic.The booth was packed at every show,and the IBM salesmen stood aroundtalking to each other.Whether or not this actually sold computerswas a question we never discussed.

Mel's job was to re-writethe blackjack program for the (? What does that mean?)The new computer had a one-plus-one,in which each machine instruction,in addition to the and the address of the needed ,had a second address that indicated where, on the revolving drum,the next instruction was located.

In modern parlance,every single instruction was followed by a !Put that in 's pipe and smoke it.

Mel loved the because he could optimize his code:that is, locate instructions on the drumso that just as one finished its job,the next would be just arriving at the "read head"and available for immediate execution.There was a program to do that job,an "optimizing assembler",but Mel refused to use it.

"You never know where it's going to put things",he explained, "so you'd have to use separate constants".

It was a long time before I understood that remark.Since Mel knew the numerical valueof every operation code,and assigned his own drum addresses,every instruction he wrote could also be considereda numerical constant.He could pick up an earlier "add" instruction, say,and multiply by it,if it had the right numeric value.His code was not easy for someone else to modify.

I compared Mel's hand-optimized programswith the same code massaged by the optimizing assembler program,and Mel's always ran faster.That was because the "" method of program designhadn't been invented yet,and Mel wouldn't have used it anyway.He wrote the innermost parts of his program first,so they would get first choiceof the address locations on the drum.The optimizing assembler wasn't smart enough to do it that way.

Mel never wrote , either,even when the balky required a delay between output characters to work right.He just located instructions on the drumso each successive one was just past the read headwhen it was needed;the drum had to execute another complete revolutionto find the next instruction.He coined an unforgettable term for this procedure.Although "" is an absolute term,like "unique", it became common verbal practiceto make it relative:"not quite " or "less "or "not very ".Mel called the maximum time-delay locationsthe "most ".

After he finished the blackjack programand got it to run("Even the initializer is optimized",he said proudly),he got a Change Request from the sales department.The program used an elegant (optimized)random number generatorto shuffle the "cards" and deal from the "deck",and some of the salesmen felt it was too fair,since sometimes the customers lost.They wanted Mel to modify the programso, at the setting of a sense switch on the console,they could change the odds and let the customer win.

Mel balked.He felt this was patently dishonest,which it was,and that it impinged on his personal integrity as a programmer,which it did,so he refused to do it.The Head Salesman talked to Mel,as did the Big Boss and, at the boss's urging,a few Fellow Programmers.Mel finally gave in and wrote the code,but he got the backwards,and, when the sense switch was turned on,the program would cheat, winning every time.Mel was delighted with this,claiming his subconscious was uncontrollably ethical,and adamantly refused to fix it.

After Mel had left the company for greener pa$ture$,the Big Boss asked me to look at the codeand see if I could find the and reverse it.Somewhat reluctantly, I agreed to look.Tracking Mel's code was a real adventure.

I have often felt that programming is an art form,whose real value can only be appreciatedby another versed in the same arcane art;there are lovely gems and brilliant coupshidden from human view and admiration, sometimes forever,by the very nature of the process.You can learn a lot about an individualjust by reading through his code,even in .Mel was, I think, an unsung genius.

Perhaps my greatest shock camewhen I found an innocent that had no in it.No . None.Common sense said it had to be a closed ,where the program would circle, forever, endlessly.Program control passed right through it, however,and safely out the other side.It took me two weeks to figure it out.

The computer had a really modern facilitycalled an index .It allowed the programmer to write a program that used an indexed instruction inside;each time through,the number in the index was added to the address of that instruction,so it would referto the next datum in a series.He had only to increment the index each time through.Mel never used it.

Instead, he would pull the instruction into a machine ,add one to its address,and store it back.He would then execute the modified instructionright from the .the was written so this additional execution timewas taken into account —just as this instruction finished,the next one was right under the drum's read head,ready to go.But the had no test in it.

The vital clue came when I noticedthe index ,the that lay between the addressand the in the instruction word,was turned onyet Mel never used the index ,leaving it zero all the time.When the light went on it nearly blinded me.

He had located the data he was working onnear the top of memory —the largest locations the instructions could addressso, after the last datum was handled,incrementing the instruction addresswould make it overflow.The carry would add one to theoperation code, changing it to the next one in the instruction set:a .Sure enough, the next program instruction wasin address location zero,and the program went happily on its way.

I haven't kept in touch with Mel,so I don't know if he ever gave in to the flood ofchange that has washed over programming techniquessince those long-gone days.I like to think he didn't.In any event,I was impressed enough that I quit looking for theoffending test,telling the Big Boss I couldn't find it.He didn't seem surprised.

When I left the company,the blackjack program would still cheatif you turned on the right sense switch,and I think that's how it should be.I didn't feel comfortablehacking up the code of a .

(cc) Mel's Loop
A Comprehensive Guide to The Story of Mel

Mel’s Loop is a guide to the epic hacker folklore tale "The Story of Mel". It also aims to collect the stories and sub-stories around the tale, its author, and its main characters, as well as early computing era stories and other related tales.