Historians Recreate Source Code of First 4004 Application 159
mcpublic writes "The team of 'digital archaeologists' who developed the technology behind the Intel Museum's 4004 microprocessor exhibit have done it again. 36 years after Intel introduced their first microprocessor on November 15, 1971, these computer historians have turned the spotlight on the first application software ever written for a general-purpose microprocessor: the Busicom 141-PF calculator. At the team's web site you can download and play with an authentic calculator simulator that sports a cool animated flowchart. Want to find out how Busicom's Masatoshi Shima compressed an entire four-function, printing calculator into only 1,024 bytes of ROM? Check out the newly recreated assembly language "source code," extensively analyzed, documented, and commented by the team's newest member: Hungary's Lajos Kintli. 'He is an amazing reverse-engineer,' recounts team leader Tim McNerney, 'We understood the disassembled calculator code well enough to simulate it, but Lajos really turned it into "source code" of the highest standards.'"
Only 1024? (Score:1)
Volume Serial Number is 1CB0-998C
Directory of c:\WINDOWS\system32
08/23/2001 10:00 AM 114,688 calc.exe
1 File(s) 114,688 bytes
0 Dir(s) 50,615,652,352 bytes free
Re: (Score:3, Interesting)
And scientific functions.
And the ability to convert hex.
And store/recall.
The original had 4 functions. This one has at least 40. Would you rather the MS guys spend time seeing if they can force their 114k application down into 10k, or perhaps writing an operating system that doesn't suck?
Re:Only 1024? (Score:5, Funny)
It'd be an improvement if MS did either.
Re: (Score:3, Funny)
Re: (Score:1)
Re: (Score:2, Funny)
Re: (Score:1, Interesting)
Try that in 1024 bytes
Re: (Score:2)
Or at least that it would do "=(10.1)-10-0.1" properly
Re:Only 1024? (Score:5, Interesting)
Re:Mod Up Interesting! (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Yeah, but I bet they do that by relying on shared libraries. The size of the executable doesn't really tell us much these days
Re: (Score:2)
Or is there a reason why the Windows calculator cant use them but the KDE one can?
Re: (Score:2)
My point is that executable size is not by itself a useful basis for comparison of the resources used by a program or how easy it was to write. If you compare two stand-alone programs, you can reasonably say that one is more compact than the other, and it will very likely be true that the smaller program required greater skill to write. If you compare a program that makes extensive use of libraries with one that doesn't, you can't make the same comparison. The shorter program was very likely the easier one
Re: (Score:3, Informative)
Those were fun (Score:5, Interesting)
Re: (Score:3, Interesting)
Re: (Score:3, Funny)
Re: (Score:2)
Remain where you are. The Software Police will be there momentarily.
Please post this code. (Score:3, Interesting)
People are still writing assembler code for tiny microprocessors. However now it is being done for very inexpensive microcontrollers like the Atmel AVR and the Microchip PIC. This ICs have all their major components integrated (like program ROM, limited RAM, UARTs, and ADC) and sell for about $1-$2. This business is moving
Re: (Score:2)
the middle of '86, and by that time I was well underway in programming in C. Also the storage medium of the day (compact cassette tape) does not lend itself to easy backing up or transfer to new media. A friend of mine (Henri Groeneweg) may have some stuff stashed away from those days but I certainly don't. Two intercontinental moves and a pretty hectic life have parted me with most of my belongings older tha
Re: (Score:3, Interesting)
to make it a little easier to relate to I said color computer but in fact it was a very little known
clone called the Dragon 32 (which, incidentally as we found out had 64K that you could use if you
pulled a few tricks).
I wished I had known about OS/9 at the time (but this was long before the age of easy access to
information and in Europe).
But hey, why am I feeding the trolls... anonymous ones at that
I gu
large function in small code (Score:2, Informative)
Re: (Score:2, Interesting)
However, the PDP-8 was a 12-bit-word minicomputer that was designed for inexpensive general-purpose computing, whereas the 4004 was (IIRC) a "tiny" 4-bit-word microchip designed mainly for numerical control applications.
I programmed both, the latter for a friend of mine when I was about 15 years old (he later basically got me my first "real" job as a Software Engineer at Pr1me), and the -8 was definitely much easier to program, with a much more powerful instruction set — the code my friend needed wri
Re: (Score:2, Interesting)
Re: (Score:3, Interesting)
Re: (Score:2)
--jeffk++
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
I thought they only guaranteed things would link properly if characters were unique in the first six characters because of FORTRAN linkers that couldn't deal with more than that.
But then, I'm a youngin', so I don't know firsthand.
Re: (Score:2)
Re: (Score:2, Funny)
Why the abuse?
Did he overcharge you?
Re: (Score:2)
but... (Score:1, Offtopic)
Re: (Score:1)
Re: (Score:2)
Re: (Score:1)
Re: (Score:3, Funny)
Re: (Score:2)
Your comment violated the "postercomment" compression filter. Try less whitespace and/or less repetition. Comment aborted.
Re: (Score:2)
And best of all (Score:5, Funny)
and in Vista (Score:2)
slashdot headline, 2057: (Score:5, Funny)
(truth be told, quick scanning the headlines, that's what my brain registered)
Re: (Score:2)
My second was related to a highly rated Bash joke about plums.
I hate to be a pendantic jerk, but... (Score:4, Funny)
What the hell is an authentic simulator?
Re:I hate to be a pendantic jerk, but... (Score:5, Funny)
zing!
Re:I hate to be a pendantic jerk, but... (Score:4, Funny)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Touche!
Quickly -- someone send this to MS (Score:4, Funny)
The output (Score:1)
the output is (Score:5, Funny)
Re: (Score:1, Funny)
Commander Keen (Score:5, Interesting)
For anyone who would like to take a look, I've put the re-engineered source code [insomnia.org] up.
Re: (Score:1, Funny)
Re: (Score:2)
Re:Commander Keen (Score:5, Interesting)
The loop is drawing columns (vertical slivers of wall). It needs to interpolate between two things: the input wall texture, and the output part of the screen. Carmack uses something like Bresenham's line drawing algorithm to do this, but because the 386 has such a limited register set, he stores the fractional increment in an immediate attached to the "addl" instruction: and elsewhere...
Re: (Score:2)
Re: (Score:2)
Registers: ebp holds a fixed point integer which represents a position within the column. 25 bits hold the fractional part. For each pixel, esi holds the memory offset of the column texture. eax and ebx hold the memory offset of the colour translation table, which is used for lighting effects. This address has to be aligned to a 256 byte boundary for reasons that will become clear.
Re: (Score:2, Informative)
generates some code like this
The first two bytes are addl,ebp and the rest are the constant.
Now what Carmack wants to do here is to have an extra register to hold a constant so he overwrites the constant in the instruction. Patch1+2 is where the constant is
Re: (Score:3)
That is indeed impressive code, but John claims he didn't write it. In fact, nobody at id has claimed authorship of it. It was speculated that perhaps Michael Abrash wrote it, but he denies authorship as well. My speculation is that it was a cool snippet of code floating around the public domain, and somebody at id had the good judgment to realize that it was significantly faster than the stan
Re: (Score:2)
http://www.beyond3d.com/content/articles/15/ [beyond3d.com]
Re: (Score:2)
Here's what I'm driving at: I did a rather deep survey of some Quake2 code about 10 years ago and found that it too called the animation control routines "think" functions. Same kind of hackery there too: structs with functions attached.
The part I liked the most (in Q2) was where the save routine simply copied the entire array of game entities to disk as one big slab of bits, taking care to
Re: (Score:2)
How to build a CPU -- transistor level up! (Score:4, Informative)
Anyway, reading about how hard it was to recreate the source code from the 4004 makes me wonder how easily we could find source code for some apps from even a decade ago. Lots of companies have gone bankrupt / discontinued products / been sold / etc, and we all know that lots of people aren't good about backing up their code. It's neat to go to the Linux Kernel Archives and look at the Historic Linux sources [kernel.org].
--
Educational microcontroller kits for the digital generation. [nerdkits.com]
Re: (Score:1, Offtopic)
Those of us with signature viewing disabled will still see the link to your website above your comment.
Re: (Score:2)
Can't find them? Should be on the shelf there somewhere. There must be a lot of old kit you can use to desolder TTL circuit components. You may need to build a Heathkit http://en.wikipedia.org/wiki/Heathkit/ [wikipedia.org] dual-trace CRO first though.
Geez I'm getting old.
Amazing! (Score:5, Insightful)
'He is an amazing reverse-engineer,' recounts team leader Tim McNerney, 'We understood the disassembled calculator code well enough to simulate it, but Lajos really turned it into "source code" of the highest standards.'
No disrespect to Lajos, but have we really fallen so far in programming standards that it's considered "amazing" to disassemble a 1024 byte program? Back in my day (and stay the hell off my lawn!) we used to disassemble programs all the time. I reverse engineered the operating system for a computer I developed for because we wanted to hook into places that weren't accessible.
Disassembly is apparently a lost art in these decadent days of some programmers never using anything but scripting languages (e.g., Java, Python, Perl) and having no clue what goes on under the hood.
Re: (Score:2)
Good question. Lets look at the excerpt from TFA included in TFS:
Sure looks to me that what Lajos is being credited with isn't the disassembl
Re: (Score:2)
'He is an amazing reverse-engineer,' recounts team leader Tim McNerney, 'We understood the disassembled calculator code well enough to simulate it, but Lajos really turned it into "source code" of the highest standards.' [...] Sure looks to me that what Lajos is being credited with isn't the disassembly, at all.
I disagree, McNerney seems to be saying that they understood the machine language well enough to simulate the calculator, but Lajos disassembled and commented the source code so that they underst
Re:Amazing! (Score:4, Insightful)
From a theoretical point of view, assembly knowledge isn't particularly useful because it doesn't lend itself to rigorous analysis (the "science" part of "computer science"). From a practical point of view, since very few programs are written in assembly language anymore, knowledge of it has limited utility. Further, from a practical point of view, I'd much rather deal with a programmer who can explain his work in terms of data structures and algorithms than one that is stuck thinking in terms of registers and memory locations.
There is certainly a place for assembly knowledge*. It's just a niche, and not a particularly important one anymore. Meanwhile, there are lots and lots of diverse applications for the theory they teach you in those classes instead of assembly. In my own work, I've had to bust out the graph theory way more often than I've had to bust out my knowledge of asm tricks for fast line-rendering...
*) Interestingly enough, one of those places is inside the language runtimes of high-level languages. There are usually lots of neat tricks inside those things (eg: using the NaN space of double-precision floats to store unions of floats and 51-bit integers without extra variant tags!)
Re: (Score:2)
I've written an assembler, for x86 no less. MOD/RM and SIB ain't got nothing on me.
Re: (Score:2)
Its odd that he would say "disassembled code" if he meant "machine language".
Re:Amazing! (Score:4, Interesting)
Re: (Score:2)
No disrespect to Lajos, but have we really fallen so far in programming standards that it's considered "amazing" to disassemble a 1024 byte program?
I dunno. I'm certain I could look at any given one kilobyte program and tell you "that opcode is adding the results of those two", but it takes a certain kind of cleverness to figure out why it's using opcodes for constants and how they manage to pack a shift-right-branch-if-odd into two bytes plus an index register.
See also "The Story Of Mel" [pbm.com]. Now imagine being tasked with turning that into readable, understandable code. That's the real accomplishment.
Re: (Score:2)
Don't have to imagine. Well, that's not quite true; I've never done anything on the scale of drum timing. But "disassembly" isn't just "opcode 53 adds X to the accumulator"; that part's (nearly) always been easy and automated. The hard part is going through, figuring out what every single memory location is for, making up your own consistent label for it, understanding the self-modifying part of the code, etc. Disassembly is a
Re: (Score:2)
Been there, done all of that. And no, what he did isn't extremely difficult or novel, but I still give him credit for pulling off nice work.
Re: (Score:2, Funny)
Re: (Score:2)
If you read the fine source code linked to in the article, you would see that not only is the machine code disassembled, but the virtual machine that it implements is fully described. That's not a trivial exercise.
Re: (Score:2)
It's one thing to disassemble a 64Kb program handwritten in assembly, or using a compiler from a relatively low-level language (such
Backups? (Score:1)
55378008 (Score:2)
My 4004 Project (Score:1)
Where's the update? (Score:5, Funny)
vista calc.exe properties (Score:2)
Size: 172 KB (176,128 bytes)
kinda puts things in perspective, doesn't it?
ah, "progress"
I have the original 4004 reference guide (Score:2)
People used to consider square wave logic charts a programming tool back then, too.
Asimov's The Feeling of Power (Score:3, Interesting)
The Feeling Of Power
by Isaac Asimov
Jehan Shuman was used to dealing with the men in authority on long-embattled earth. He was only a civilian but he originated programming patterns that resulted in self-directing war computers of the highest sort. Generals, consequently listened to him. Heads of congressional committees too.
There was one of each in the special lounge of New Pentagon. General Weider was space-burned and had a small mouth puckered almost into a cipher. He smoked Denebian tobacco with the air of one whose patriotism was so notorious, he could be allowed such liberties.
Shuman, tall, distinguished, and Programmer-first-class, faced them fearlessly.
He said, "This, gentlemen, is Myron Aub."
"The one with the unusual gift that you discovered quite by accident," said Congressman Brant placidly. "Ah." He inspected the little man with the egg-bald head with amiable curiosity.
The little man, in return, twisted the fingers of his hands anxiously. He had never been near such great men before. He was only an aging low-grade technician who had long ago failed all tests designed to smoke out the gifted ones among mankind and had settled into the rut of unskilled labor. There was just this hobby of his that the great Programmer had found out about and was now making such a frightening fuss over.
General Weider said, "I find this atmosphere of mystery childish."
"You won't in a moment," said Shuman. "This is not something we can leak to the firstcomer. Aub!" There was something imperative about his manner of biting off that one-syllable name, but then he was a great Programmer speaking to a mere technician. "Aub! How much is nine times seven?"
Aub hesitated a moment. His pale eyes glimmered with a feeble anxiety.
"Sixty-three," he said.
Congressman Brant lifted his eyebrows. "Is that right?"
"Check it for yourself, Congressman."
The congressman took out his pocket computer, nudged the milled edges twice, looked at its face as it lay there in the palm of his hand, and put it back. He said, "Is this the gift you brought us here to demonstrate. An illusionist?"
"More than that, sir. Aub has memorized a few operations and with them he computes on paper."
"A paper computer?" said the general. He looked pained.
"No, sir," said Shuman patiently. "Not a paper computer. Simply a piece of paper. General, would you be so kind as to suggest a number?"
"Seventeen," said the general.
"And you, Congressman?"
"Twenty-three."
"Good! Aub, multiply those numbers, and please show the gentlemen your manner of doing it."
"Yes, Programmer," said Aub, ducking his head. He fished a small pad out of one shirt pocket and an artist's hairline stylus out of the other. His forehead corrugated as he made painstaking marks on the paper.
General Weider interrupted him sharply. "Let's see that."
Aub passed him the paper, and Weider said, "Well, it looks like the figure seventeen."
Congressman Brant nodded and said, "So it does, but I suppose anyone can copy figures off a computer. I think I could make a passable seventeen myself, even without practice."
"If you will let Aub continue, gentlemen," said Shuman without heat.
Aub continued, his hand trembling a little. Finally he said in a low voice, "The answer is three hundred and ninety-one."
Congressman Brant took out his computer a second time and flicked it. "By Godfrey, so it is. How did he guess?"
"No guess, Congressman," said Shuman. "He computed that result. He did it on this sheet of paper."
"Humbug," said the general impatiently. "A computer is one thing and marks on a paper are another."
"Explain, Aub," said Shuman.
"Yes, Programmer. Well, gentlemen, I write down seventeen, and just undernea
1024 Bytes? Bah! (Score:3, Interesting)
LS
Re: (Score:3, Funny)
Re: (Score:2)
Re:Something is wrong...... (Score:4, Informative)
"The electronic calculators that accountants used 35 years ago worked differently than the familiar four-function calculator we use today. These were designed to behave much like mechanical adding machines of the 1960's. After every number you want to add to the total, you need to press +, so = doesn't work like you'd expect. Here are some examples:
To add three numbers: 61 + 79 + 83 + = (if you forget the last +, the 83 won't get added)
To subtract two numbers: 2007 + 1971 - =
To multiply two numbers: 125 x 5 = (this is more like we're used to)
To divide two numbers: 625 / 5 = "
Re: (Score:2)
Millions of people still use calculators that behave exactly like that. All financial calculators work like that, and for good reason.
Dan East