Slashdot Mirror


Historians Recreate Source Code of First 4004 Application

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

159 comments

  1. Only 1024? by snoyberg · · Score: 0

    Volume in drive C is NTSWIM100
      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

    --
    Thank God for evolution.
    1. Re:Only 1024? by jfengel · · Score: 2, Interesting

      The original lacked a gui.

      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?

    2. Re:Only 1024? by DragonWriter · · Score: 5, Funny

      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?


      It'd be an improvement if MS did either.
    3. Re:Only 1024? by geekoid · · Score: 2, Funny

      I'm pretty sure it had a GUI. I'f I were to guess, I'd say it was buttons...possibly with numbers on them.

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    4. Re:Only 1024? by Merls+the+Sneaky · · Score: 1

      I think you will find that was a PUI (physical user interface)

    5. Re:Only 1024? by Anonymous Coward · · Score: 1, Interesting

      A lot of people don't know this, but Windows' Calc.exe actually implements arbitrary precision math. Don't believe me? Calculate 20000!, or calculate 1/3 and repeatedly multiply by 10 and subtract 3.

      Try that in 1024 bytes :)

    6. Re:Only 1024? by cheater512 · · Score: 1

      The KDE guys have gotten theirs to about 5k with a somewhat more functionality than Window's.

    7. Re:Only 1024? by megaditto · · Score: 1

      I kind of wish their Excel could do at least 200!
      Or at least that it would do "=(10.1)-10-0.1" properly

      --
      Obama likes poor people so much, he wants to make more of them.
    8. Re:Only 1024? by billcopc · · Score: 1

      Yep, the old Microsoft was great. The new Microsoft is just plain retarded.

      Any tard can slap new eyecandy on a tired old app, especially when you're selling it to even bigger tards.

      Windows Calc is quite possibly the most abused utility in my arsenal, even more than Notepad.

      --
      -Billco, Fnarg.com
    9. Re:Only 1024? by belmolis · · Score: 1

      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

    10. Re:Only 1024? by cheater512 · · Score: 1

      Whats your point? Windows suddenly doesnt have shared libraries?
      Or is there a reason why the Windows calculator cant use them but the KDE one can? :P

    11. Re:Only 1024? by ppc_digger · · Score: 3, Informative
      They put all the actual code in a shared library:

      # ldd /usr/bin/kcalc
      libkdeinit_kcalc.so => /usr/lib/libkdeinit_kcalc.so (0x00002b1351db8000)
      ...

      # ls -lh /usr/lib/libkdeinit_kcalc.so
      -rw-r--r-- 1 root root 436K 2007-07-03 19:15 /usr/lib/libkdeinit_kcalc.so
      --
      Of all major operating systems, UNIX is the only one originally meant for gaming.
    12. Re:Only 1024? by TDRighteo · · Score: 5, Interesting
      Floating-point math doesn't fix itself. Let's not be hard on Microsoft when:

      Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11)
      [GCC 4.1.2 20070925 (Red Hat 4.1.2-33)] on linux2
      Type "help", "copyright", "credits" or "license" for more information.
      >>> 10.1-10-0.1
      -3.6082248300317588e-16
      and...

      $ perl
      printf("%s\n", 10.1-10-0.1);
      -3.60822483003176e-16
      and...

      $ php
      <?php
      echo (10.1-10-0.1);
      ?>
      -3.6082248300318E-16
      Note that the answers vary across languages too...
    13. Re:Only 1024? by belmolis · · Score: 1

      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 to write because all the real work is done by the libraries, and there is no way to tell, just by looking at the programs themselves, which uses more memory.

      For example, I am told that Internet Explorer is actually a rather modest shell and that much of the work is done by system calls. If this is true, IE is much smaller than say Firefox or Konqueror, but not in a meaningful way. Certainly, this would not be a reasonable basis for claiming that IE is coded more compactly and cleverly than the others.

    14. Re:Only 1024? by dotgain · · Score: 2, Funny

      I wonder why that acronym never caught on?

    15. Re:Only 1024? by Anonymous Coward · · Score: 0

      I hope that you realize that this application relies heavily on dlls from the OS. So this is not a true indication of the size.

    16. Re:Only 1024? by Anonymous Coward · · Score: 0

      Those answers are all the same, except with progressively less precision. lrn2number

    17. Re:Only 1024? by tkw954 · · Score: 1

      Same on Matlab and Octave.

    18. Re:Only 1024? by FlashBuster3000 · · Score: 1

      at least python gives the higher precision

    19. Re:Only 1024? by corpsmoderne · · Score: 1

      -3.6082248300317588e-16
      -3.60822483003176e-16
      -3.6082248300318E-16
      Note that the answers vary across languages too...
      The asnwers vary, not the results. The differences are in the default printing method of each language
    20. Re:Only 1024? by Anonymous Coward · · Score: 0

      Same on Matlab and Octave.

      And Maxima. However, if I enter it as (10+1/10) - 10 - (1/10), I get the correct answer. =)

    21. Re:Only 1024? by Anonymous Coward · · Score: 0

      I really don't see this as being a big deal. 1K is large for what this does, at least compared to what the demoscene guys are doing.

      http://pouet.net/prodlist.php?type%5B%5D=32b&type%5B%5D=64b&type%5B%5D=128b&type%5B%5D=256b&type%5B%5D=512b&type%5B%5D=1k&order=&x=19&y=9&page=1&order=

    22. Re:Only 1024? by laejoh · · Score: 0

      Note that the answers vary across languages too...

      Indeed:

      0.10 IDENTIFICATION DIVISION.
      0.20 PROGRAM-ID. JL01A.
      0.40 ENVIRONMENT DIVISION.
      0.50 CONFIGURATION SECTION.
      0.60 SPECIAL-NAMES.
      0.70 TERMINAL IS TERM.
      0.80 INPUT-OUTPUT SECTION.
      1.00 DATA DIVISION.
      1.10 FILE SECTION.
      1.30 WORKING-STORAGE SECTION.
      1.40 77 ANSWER PIC 99V99.
      1.50 77 ANSWEROUT PIC +99.99.
      1.70 PROCEDURE DIVISION.
      1.80 JL01A.
      2.00 COMPUTE ANSWER = 10.1 - 10 - 0.1.
      2.10 MOVE ANSWER TO ANSWEROUT.
      2.20 DISPLAY "THE ANSWER IS " ANSWEROUT UPON TERM.
      2.30 *
      2.40 FIN.
      2.50 STOP RUN.

      THE ANSWER IS +00.00

      Please note that slashdot isn't very cobol friendly, it messes up the layout of the source :(

    23. Re:Only 1024? by ioshhdflwuegfh · · Score: 1

      Easy fix:
      $ clisp -q
      [1]> (- 10.1d0 10 0.1d0)
      -3.608224830031759d-16
      [2]> (- 10.1d0 0.1d0 10)
      0.0d0

    24. Re:Only 1024? by elkto · · Score: 1

      -3.6082248300317588e-16 -3.60822483003176e-16 -3.6082248300318E-16 Err.... What??? They are the same answer, just printed at different points of rounding.

    25. Re:Only 1024? by elkto · · Score: 1

      Opps, my self=idiot light just illuminated. 0

    26. Re:Only 1024? by raddan · · Score: 1

      The important question is, why is Excel using floating-point for Math? There are plenty of decimal math libraries out there, and I'm sure Microsoft could bang out a pretty good one themselves if they cared enough to do so.

    27. Re:Only 1024? by Bluehorn · · Score: 1

      [Example programs to compute 10.1 - 10.0 - 0.1 in different scripting languages] python: -3.6082248300317588e-16 perl: -3.60822483003176e-16 php: -3.6082248300318E-16

      Note that the answers vary across languages too... Strikes me. You've never heard about the innovative concept called rounding, have you?
    28. Re:Only 1024? by mollymoo · · Score: 1

      Commodity CPUs have hardware support for floating point operations but not decimal operations, which means floating point is much faster than decimal.

      --
      Chernobyl 'not a wildlife haven' - BBC News
    29. Re:Only 1024? by raddan · · Score: 1

      True, but-- we're talking about a spreadsheet. How much number-crunching capability do people need? I suspect that anyone whose computational requirements are sufficient enough to require real numerical horsepower already understands the limitations of floating-point math. Very few normal Excel users do, and I think, for them, a program that meets their expectations-- that is, a program that does arbitrary precision decimal math, accurately-- is more important than speed.

    30. Re:Only 1024? by squiggleslash · · Score: 1

      Just did that in Ubuntu 7.04's default GNOME calculator and got the answer "-0". Minus Zero. Cool!

      Looks like a lot of software has issues with that equation.

      --
      You are not alone. This is not normal. None of this is normal.
    31. Re:Only 1024? by squiggleslash · · Score: 1

      Try doing the calculation manually, and don't round your answers; bet you can't beat Python's "precision"!

      --
      You are not alone. This is not normal. None of this is normal.
  2. Heh - non-commercial purposes only by Anonymous Coward · · Score: 0

    I wonder if they can still make some $$ off of this code in small embedded applications?

  3. Those were fun by certsoft · · Score: 4, Interesting

    Somewhere around 1975 or 1976 I wrote software for a 4004 (using a teletype connected to a modem connected to a mainframe someplace that had the assembler) to run a X-Y table. You would place a wafer with thick-film resistors on it and it would test each one to make sure it was within tolerance and if it wasn't it would mark it with magnetic ink. I think we were probably still using the infamous 1702 EPROMs but there might have been something newer at that time.

    1. Re:Those were fun by jacquesm · · Score: 2, Interesting

      somewhere around 1982 a buddy of mine and myself disassembled and commented microsoft's basic for the trs-80 color computer. Then we improved it with tons of new statements via the hook in ram. Documenting a bloody calculator is childs play compared to that and we weren't especially proud of it, just curious.

    2. Re:Those were fun by PopeRatzo · · Score: 2, Funny

      somewhere around 1982 a buddy of mine and myself disassembled and commented microsoft's basic for the trs-80 color computer.
      And you lived to tell the tale.
      --
      You are welcome on my lawn.
    3. Re:Those were fun by dmonahan · · Score: 1

      I wrote a machine tool controller for the 4004. The Intel salesman told us we had one of the first chips in the Boston area. A little while later, he sold us the "first" 8008 in the area.

      Dick.

    4. Re:Those were fun by ozmanjusri · · Score: 2, Funny
      A little while later, he sold us the "first" 8008 in the area. Dick.

      Why the abuse?

      Did he overcharge you?

      --
      "I've got more toys than Teruhisa Kitahara."
    5. Re:Those were fun by belmolis · · Score: 1

      Remain where you are. The Software Police will be there momentarily.

    6. Re:Those were fun by Anonymous Coward · · Score: 0

      somewhere around 1982 a buddy of mine and myself disassembled and commented microsoft's basic for the trs-80 color computer. Then we improved it with tons of new statements via the hook in ram. Documenting a bloody calculator is childs play compared to that and we weren't especially proud of it, just curious.


      Bullshit.. you had better tools than the parent poster did. In fact, you're probably a little puss that actually used a disassembler instead of doing it by hand.

      And yeah, what YOU did was child's play. A real hacker would have been using OS9.
    7. Re:Those were fun by jacquesm · · Score: 2, Interesting

      the tools we had were the Leventhal 6809 book, we wrote the disassembler (and the assembler) ourselves,
      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 guess it is because I wonder what has become of the software scene that we now have f'ing laws
      that stop kids from being curious and looking 'inside the box'.

    8. Re:Those were fun by ATMD · · Score: 1

      GP's name is Richard. He's just signing off his post.

      --
      Nobody else has this sig.
  4. but... by malraid · · Score: 0, Offtopic

    does it run linux? ... lame!

    --
    please excuse my apathy
    1. Re:but... by andreyvul · · Score: 1

      No: 4-bit devices are outside the range of Linux.

      --
      proud caffeine whore
    2. Re:but... by sqrt(2) · · Score: 1

      That sounds like a dare to me.

      --
      If you build it, nerds will come. Soylentnews.org
    3. Re:but... by andreyvul · · Score: 1

      Here's a real dare: have linux work on a 1-bit turing machine that has no registers

      --
      proud caffeine whore
    4. Re:but... by Anonymous Coward · · Score: 3, Funny

      Did it, but the ATI drivers still sucked.

    5. Re:but... by McGiraf · · Score: 1

      whah! ah! ah! ah! ah! ah!

      Your comment violated the "postercomment" compression filter. Try less whitespace and/or less repetition. Comment aborted.

  5. And best of all by Dusty · · Score: 4, Funny

    You can still run it on the latest Intel x86 chips. ;)

    1. Re:And best of all by noidentity · · Score: 1

      Looks like the 4004 has more registers. From the comments of the source: ;R0..R15 i4004 register 0..15

      Pretty pathetic!

  6. slashdot headline, 2057: by circletimessquare · · Score: 4, Funny

    "Historians Recreate Source Code of First 404 Error Message"

    (truth be told, quick scanning the headlines, that's what my brain registered)

    --
    intellectual property law is philosophically incoherent. it is your moral duty to ignore it or sabotage it
    1. Re:slashdot headline, 2057: by MooUK · · Score: 1

      That was my first thought too.

      My second was related to a highly rated Bash joke about plums.

  7. I hate to be a pendantic jerk, but... by gatekeep · · Score: 3, Funny

    "...an authentic calculator simulator..."

    What the hell is an authentic simulator?

    1. Re:I hate to be a pendantic jerk, but... by urcreepyneighbor · · Score: 5, Funny

      Your hand?

      zing!

      --
      "The fight for freedom has only just begun." - Geert Wilders
    2. Re:I hate to be a pendantic jerk, but... by Vegeta99 · · Score: 3, Funny

      Na way man, Jill never needs flowers or taken out to dinner. She's better than authentic!

    3. Re:I hate to be a pendantic jerk, but... by LarsG · · Score: 1

      I suppose one would have to use genuine emulation.

      --
      If J.K.R wrote Windows: Puteulanus fenestra mortalis!
    4. Re:I hate to be a pendantic jerk, but... by vocaro · · Score: 1

      I hate to be a pedantic jerk, but you misspelled pedantic.

    5. Re:I hate to be a pendantic jerk, but... by gatekeep · · Score: 1

      I hate to be a pedantic jerk, but you misspelled pedantic.

      Touche!

    6. Re:I hate to be a pendantic jerk, but... by Dr.+Cody · · Score: 1

      She's got a kinky sister, too.

    7. Re:I hate to be a pendantic jerk, but... by mcpublic · · Score: 1

      By "authentic" I mean the original Busicom 141-PF calculator firmware running on an Intel 4004 instruction-level simulator with printer and keyboard hardware simulated in software. This is all described in the documentation available at http://www.4004.com/

  8. Quickly -- someone send this to MS by Eberlin · · Score: 4, Funny

    Quick, someone send this over to the folks who wrote Excel!

    1. Re:Quickly -- someone send this to MS by Ken_g6 · · Score: 1

      Did you read section 4.6?

      "...'10.01 / 3 = Ex / 3 =' gives '666666666666.6'."

      Bad idea!

      --
      (T>t && O(n)--) == sqrt(666)
  9. uhhhh... by Anonymous Coward · · Score: 0

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

    Hate to use that calc. Did a simple 9+9 and it gave me 1. or 0. or 9 + 99 is 11. the only way to get a semi-correct answer was
    9+
    9+
    +
    and it returned
    =27

    A slight bug maybe?

    1. Re:uhhhh... by Cassius+Corodes · · Score: 2, Funny

      That is the correct answer - all modern calculators are descended from a competitor's model which incorrectly calculated 9+9 to be 18.

      --
      Control is an illusion, order our comforting lie. From chaos, through chaos, into chaos we fly
    2. Re:uhhhh... by Ecuador · · Score: 0, Redundant

      Additions give me garbage too, however multiplication and SQRT worked fine. Are we doing something wrong with addition?

      --
      Violence is the last refuge of the incompetent. Polar Scope Align for iOS
    3. Re:uhhhh... by netringer · · Score: 1

      You could read the documentation. You want 9+ 9+ = At the end you did 9+9+9 You could look at what's on the tape. IHBTHIND

      --
      Ever dream you could fly? Get up from the Flight Sim. I Fly
    4. Re:uhhhh... by Anonymous Coward · · Score: 0

      And his name was John McCarthy.

  10. The output by ackthpt · · Score: 1

    Hello world!

    --

    A feeling of having made the same mistake before: Deja Foobar
  11. the output is by geekoid · · Score: 4, Funny

    58008

    --
    The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    1. Re:the output is by Anonymous Coward · · Score: 1, Funny

      Better than 55318008

  12. Commander Keen by QuantumG · · Score: 5, Interesting

    I once reverse engineered the classic id software game Commander Keen. John Carmack did some cool stuff in that code.. each sprite had two function pointers in it, one was called when the sprite came into contact with another sprite, the other was called every frame to animate the sprite (he called it the "think" function). When you killed a monster the sprite was replaced with a "body" which was just like a sprite but had a few less fields (so it took up less memory). One of the neatest things he did was use this exact same framework of sprites and bodies to animate the "static" parts of the game. For example, the color coded doors that you have to get the key cards to open were sprites with a contact function that checked if the player had the right key card, at which time they would "die" and be replaced by a body that had a think function would make them slide out of the way.

    For anyone who would like to take a look, I've put the re-engineered source code up.

    --
    How we know is more important than what we know.
    1. Re:Commander Keen by Anonymous Coward · · Score: 1, Funny

      How dare you learn something without authorization! This is a clear DMCA violation. Mr. Carmack's lawyers are on the way to your house now to execute you...errr, I mean execute their warrant to take all your computers and reclaim the code you stole. And you're distrubuting it too! Well now you're also a pirate. You're going away for a long time.

    2. Re:Commander Keen by Anonymous Coward · · Score: 0

      Bravo, and nice choice. That's some serious coding, and one of my all-time favorite games.

    3. Re:Commander Keen by Cheesey · · Score: 4, Interesting
      Carmack's code is always interesting. Most famously, there's the infamous square root approximation from Quake. But I'm still impressed by the original Doom render loop, with it's self-modifying code.

      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:

      doubleloop:
          movl ecx,ebp // begin calculating third pixel
      patch1:
          addl ebp,12345678h // advance frac pointer
          movb [edi],al // write first pixel
          shrl ecx,25 // finish calculation for third pixel
          movl edx,ebp // begin calculating fourth pixel
      patch2:
          addl ebp,12345678h // advance frac pointer
          movl [edi+SCREENWIDTH],bl // write second pixel
          shrl edx,25 // finish calculation for fourth pixel
          movb al,[esi+ecx] // get third pixel
          addl edi,SCREENWIDTH*2 // advance to third pixel destination
          movb bl,[esi+edx] // get fourth pixel
          decl [loopcount] // done with loop?
          movb al,[eax] // color translate third pixel
          movb bl,[ebx] // color translate fourth pixel
          jnz doubleloop
      and elsewhere... :)

      movl ebx,[_dc_iscale]
          shll ebx,9
          movl eax,OFFSET patch1+2 // convice tasm to modify code...
          movl [eax],ebx
      A similarly impressive trick is used to draw floors, where 3D interpolation is required because each texture needs to be crossed diagonally, not vertically. I never understood how Doom drew floors until I looked at the code, and I still think it's deep magic. And that's without even mentioning the BSP code!
      --
      >north
      You're an immobile computer, remember?
    4. Re:Commander Keen by Chris+Pimlott · · Score: 1

      Would you mine annotating this a bit more? I'm not that familiar with 386 assembly, thanks.

    5. Re:Commander Keen by pragma_x · · Score: 1

      Now that's an interesting tidbit. So I guess in a sense Keen can claim some amount of intellectual heritage to Quake?

      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 only re-write any entity pointers as indicies back into the array. Loading simply did the reverse. Fast and reliable, if a bit wasteful on disk; I wonder what other things have survived through to ID Tech 5...

    6. Re:Commander Keen by QuantumG · · Score: 1

      Heh, I wasn't aware of that, thanks for the info.

      --
      How we know is more important than what we know.
    7. Re:Commander Keen by QuantumG · · Score: 1

      Ha! What in the world makes you think Carmack still has copyright over this code? Last I heard, Tom Hall had the rights.

      --
      How we know is more important than what we know.
    8. Re:Commander Keen by Hal_Porter · · Score: 1

      patch1:
          addl ebp,12345678h
      generates some code like this

      81 C5 78 56 34 12
      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

      movl ebx,[_dc_iscale] // get the constant
          shll ebx,9 // constant <<= 9
          movl eax,OFFSET patch1+2 // get the address of the constant in the instruction
          movl [eax],ebx // overwrite it in the instruction
      So essentially the code becomes

      patch1:
          addl ebp, _dc_iscale << 9
      What I'm not sure is why he didn't do addl ebp,[FractionalIncrement]. That would take the FractionalIncrement from a memory location. Then he wouldn't need the self modifying code, he could just write _dc_iscale

      patch1:
      ; Rx holds whatever was in ebp
      ; Ry is _dc_iscale
        ldr Rx, [Rx, Ry, lsl #9]
      --
      echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
    9. Re:Commander Keen by Hal_Porter · · Score: 2, Informative
      Damnit slashdot really doesn't like

      patch1:
          addl ebp,12345678h
      generates some code like this

      81 C5 78 56 34 12
      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

      movl ebx,[_dc_iscale] // get the constant
          shll ebx,9 // constant <<= 9
          movl eax,OFFSET patch1+2 // get the address of the constant in the instruction
          movl [eax],ebx // overwrite it in the instruction
      So essentially the code becomes

      patch1:
          addl ebp, _dc_iscale << 9
      What I'm not sure is why he didn't do addl ebp,[FractionalIncrement]. That would take the FractionalIncrement from a memory location. Then he wouldn't need the self modifying code, he could just write _dc_iscale << 9 there.

      On the other hand, maybe the code is memory limited anyway and this will slow it down.

      On a recent x86 processor self modifying code will be correct but not too fast. If code is not self modifying it will execute from the instruction cache and writes will be buffered and stored in writeback data cache. Self modifying code screws with this - the write needs to end up in the i cache somehow. And x86 opcodes are converted into a Risc like internal format for execution, and if these are cached you need to flush that cache too. And since they have to do it on old code they have to do all steps automatically with no hints from the programmer.

      On an ARM you just need to clean the dcache, flush the write buffer and flush the icache as ARM instructions are a executed directly. And all these are things the programmer has to ask for explicitly using MCR and MRC instructions. Actually ironically the ARM has more registers 13 instead of 6 so you have less need for this and you can encode shift counts for free, so in ARM you could do this

      patch1:
      ; Rx holds whatever was in ebp
      ; Ry is _dc_iscale
        ldr Rx, [Rx, Ry, lsl #9] // Rx = Rx + (Ry<<9)
      --
      echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
    10. Re:Commander Keen by Anonymous Coward · · Score: 0

      damn, sorry this is way off topic but carmack(or anyone else for that matter) should throw together another 2-D platformer engine together using the doom model.

      hear me out:

      1. low cost to implement. now, i could be wrong, i'm no programmer, the closest i ever got to programming was making doom wads, and i'm sure many other people had the same experience and took up programming. i would argue that carmacks greatest contribution to gaming was allowing people to use his tools to make their own content.
      2. use the doom/quake model and license the engine and opened it up for mods. think of all of the awesome doom mods that were released. something like this could have an even lower entry barrier if was made to be easily used but as deep as you want. (Quake C anyone?) think synthmaker(synthmaker.co.uk) or spore, neverwinter nights, and so on. synthmaker is intresting because it takes something incredibly lowlevel like dsp routines and makes the greater context like putting together legos but you can still put your own code in there.
      3. in game editor, i want to be able to tweak physics like marios jump and running speed by hitting ~ and tweaking shit in the editor, hit ~ again and see the results.
      4. i don't understand why this hasn't been done yet, i mean there has been all sorts of wack shit like game maker that don't adress the core problem.
      5. Klik & Play, Click & Create, Game Maker suck, that is all.
      6. awesome primary game, people bought doom to play doom, the wads were an (albeit great) bonus.

      eh sorry for being so off topic, i just had an idea that i know i wouldn't put to good use so i thought i'd share.

    11. Re:Commander Keen by StormReaver · · Score: 2

      "Carmack's code is always interesting. Most famously, there's the infamous square root approximation from Quake."

      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 standard library sqrt().

    12. Re:Commander Keen by eison · · Score: 1

      It was tracked down to Greg Walsh, with help from Cleve Moler.
      http://www.beyond3d.com/content/articles/15/

      --
      is competition good, or is duplication of effort bad?
    13. Re:Commander Keen by niteice · · Score: 1

      Doom 3 still saves games the same way. In fact, I'm pretty sure it uses a similar think setup, though highly enhanced (mostly due to the deep scripting integration, and finally being ported to C++).

      --
      ROMANES EUNT DOMUS
    14. Re:Commander Keen by Cheesey · · Score: 1

      The self-modifying code parts have already been described by Hal Porter, but he didn't explain how the algorithm actually works.

      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. Finally, edi holds the current video memory address.

      Algorithm: For even-numbered pixels, ebp is copied to ecx and shifted right by 25 bits to obtain the texture pixel (comment says: "finish calculation"). ebp is then incremented by a fractional value that represents the ratio between screen pixels and texture pixels (that's the value inserted using self-modifying code). Then, ecx+esi is computed and dereferenced ("movb al, [esi+ecx]"). The result is stored in al - the low 8 bits of the eax register. Then, dereferencing eax gives the value of the pixel to be written to the screen. Lastly, edi is incremented to the next row.

      The same process is almost simultaneously applied to odd-numbered pixels, which use ebx, edx and bl instead.

      There are at least five clever things here. There's the self-modifying code. There's the use of eax/al to avoid an addition. There's the interleaving of two loop iterations - manual modulo scheduling. There's only one branch, so the code pipelines really well, even if the branch predictor is very primitive. And finally, there's an interpolation algorithm that doesn't use any slow multiplications or divisions. (It's not really like Bresenham's line drawing algorithm.. I was mistaken about that. If it was like Bresenham's algorithm, it would not fetch the same pixel from the texture memory twice. But it would also have to include branches on a non-predicated architecture like x86, and that would make it slower.)

      You can see more stuff like this in README.asm, included with linuxdoom-1.10, the GPL'ed Doom source release.

      --
      >north
      You're an immobile computer, remember?
    15. Re:Commander Keen by Anonymous Coward · · Score: 0

      The 'think' and 'touch' seem to have always been there from Keen to even the latest Quake -- very simple design but works pretty great. I've learned a great deal from reading carmack's code, I wonder what I'll get from the Keen code. Thanks for the explanation and the code !

    16. Re:Commander Keen by Anonymous Coward · · Score: 0

      Are you kidding? If Tom Hall had the rights, The Universe Is Toast would have been released already. He's been trying to get the rights back for years, to no avail.

  13. How to build a CPU -- transistor level up! by compumike · · Score: 3, Informative

    Take a look at this set of videos from MIT's 6.004 Computation Structures class. They basically walk through the design of a simple 32-bit CPU from transistors, to gates, to functional blocks, to a full processor.

    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.

    --
    Educational microcontroller kits for the digital generation.

    1. Re:How to build a CPU -- transistor level up! by Danny+Rathjens · · Score: 0, Offtopic

      Can you please put your advertisement in the proper signature field in your preferences instead of pasting it into the body of your message with the fake -- delimiter to fool people(search engines?) into thinking it is a normal sig?
      Those of us with signature viewing disabled will still see the link to your website above your comment.

    2. Re:How to build a CPU -- transistor level up! by Nefarious+Wheel · · Score: 1
      Simple -- buy a wire wrap tool, a breadboard kit and the TTL Handbook.

      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/ dual-trace CRO first though.

      Geez I'm getting old.

      --
      Do not mock my vision of impractical footwear
    3. Re:How to build a CPU -- transistor level up! by Zebedeu · · Score: 1

      Exactly. I have replied to this guy before with the same request, but apparently he just doesn't care, which makes him a spammer, from my point of view.

      It's not the first time I see this kind of thing (though usually it's not commercial in nature) and since the moderators don't seem interested, I wish slashdot would police this.

    4. Re:How to build a CPU -- transistor level up! by Danny+Rathjens · · Score: 1

      Well, if peer pressure doesn't work, I guess we just have to filter spamvertisers individually with a foe penalty. :)
      (My mistake to post the complaint with a karma bonus, though; I never think to disable it. So I got a well-deserved off-topic mod :)

  14. Amazing! by Reality+Master+101 · · Score: 4, 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.

    --
    Sometimes it's best to just let stupid people be stupid.
    1. Re:Amazing! by DragonWriter · · Score: 1

      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?


      Good question. Lets look at the excerpt from TFA included in TFS:

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

    2. Re:Amazing! by Just+Some+Guy · · Score: 1

      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". Now imagine being tasked with turning that into readable, understandable code. That's the real accomplishment.

      --
      Dewey, what part of this looks like authorities should be involved?
    3. Re:Amazing! by Juliemac · · Score: 2, Funny

      The company I work for hired 4 programmers (from out of country) to re-work existing code and clear out known bugs. As a result, the log in no longer worked. 2 weeks later, the testers could get in, but none of the drop down boxes worked and more. Problem is they are wizards. They click and drop code with out understanding what the code does. The US trained programmers cant get the time of day from the head of IT.

    4. Re:Amazing! by Reality+Master+101 · · Score: 1

      '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 understood what it was doing. It's the difference between the MAME guys who write a processor simulator and the guys who actually disassembly the ROMs to see how they work.

      Either task for this calculator is pretty damn simple. It's just that somehow modern programmers have been taught to fear assembly and machine language as something too arcane to be understood by mortals. I actually blame the universities who typically teach assembly language as an afterthought, rather than teach it in the first year as it ought to be.

      --
      Sometimes it's best to just let stupid people be stupid.
    5. Re:Amazing! by Jay+L · · Score: 1

      Now imagine being tasked with turning that into readable, understandable code.

      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 labor-intensive human process, not just the output of a "disassembler".

      I remember using disassemblers from my Commodore days; the more advanced ones would spot most of the standard, documented KERNAL routines and registers, but for the most part they were opcode translators and editors with good search and replace. (Keep in mind that at the time, "cut and paste" was so novel it didn't even have a common metaphor; some called it "split and glue".)

      The art was advanced enough by then that books like "Inside Commodore DOS" had, IIRC, a complete disassembly with comments, as well as the typical "reference guide" of functions and variables (all reverse engineered, of course).

      So I'm with Reality Master; yay for keeping the knowledge alive and all that, but this used to not be all that impressive a feat.

    6. Re:Amazing! by Just+Some+Guy · · Score: 1

      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.

      --
      Dewey, what part of this looks like authorities should be involved?
    7. Re:Amazing! by dmonahan · · Score: 4, Interesting

      Sometime in the early 70s, a Honeywell division, one of our steady clients, called with a strange request. They had built a small number of special machines for the Navy. Now the Navy wanted more. Honeywell had the circuit drawings and the bootable tape (which they got from the Navy). They had no documentation (not even the instruction set). They asked us to rebuild the code. We did. Dick.

    8. Re:Amazing! by be-fan · · Score: 3, Insightful

      "Programs must be written for people to read, and only incidentally for machines to execute." - Abelson & Susman

      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!)

      --
      A deep unwavering belief is a sure sign you're missing something...
    9. Re:Amazing! by NixieBunny · · Score: 1
      This is not your typical disassembly job.

      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.

      --
      The determined Real Programmer can write Fortran programs in any language.
    10. Re:Amazing! by Locklin · · Score: 1

      I wouldn't say it's a lost art -- I'm very proficient at disassembling Python, Perl and PHP. I can get at the source in a matter of seconds!

      --
      "Knowledge is the only instrument of production that is not subject to diminishing returns" -Journal of Political Econom
    11. Re:Amazing! by Anonymous Coward · · Score: 0

      Heh. I learned disassembly the old fashioned way back in high school -- removing the copy protection from Apple II games. Uphill. Both ways.

    12. Re:Amazing! by shutdown+-p+now · · Score: 1

      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.
      It's one thing to disassemble a 64Kb program handwritten in assembly, or using a compiler from a relatively low-level language (such as C) which can only do the simplest optimizations. Back in DOS days, I cracked a few games myself like that. Things are different today because high-level languages are used which often have fundamental operations that can easily correspond to several dozen asm instructions each, and executables tend to be large, easily going into several megabytes. Add a decent modern optimizer to that, the kind that will agressively inline calls (who compiles for size rather than speed on the desktop these days?), and rearrange code and data access seemingly at random to get the most out of jump predictor and cache, and you get a real mess to disassemble. Looking at output generated by gcc at -O3 for C++ code that heavily uses STL can be enlightening at times.
    13. Re:Amazing! by Anonymous Coward · · Score: 0

      I recall having seen a pacman disassembly fully commented a couple of years ago. That is a great reverse engineering effort. 1024 bytes of a calculator doesn't seem as an amazing achievement to me.

    14. Re:Amazing! by noidentity · · Score: 1

      The video game console emulation community has many people who still write asm and reverse-engineer games (and the hardware too). One common need is when "ripping" the music playback code from a game, to allow playback in a game music player, which emulates the original sound chip and processor. There are thousands of such rips available.

    15. Re:Amazing! by ioshhdflwuegfh · · Score: 1

      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. Then I gather you have not really programmed much, have you? Like in assembler, say 8-bit, or something similar? Just another pie-eater, ha?

      "Programs must be written for people to read, and only incidentally for machines to execute." - Abelson & Susman Well that's the beauty of assembler, it is written for both people to read and machines to execute, non-incidentally.
    16. Re:Amazing! by be-fan · · Score: 1

      Then I gather you have not really programmed much, have you? Like in assembler, say 8-bit, or something similar? Just another pie-eater, ha?

      I've written an assembler, for x86 no less. MOD/RM and SIB ain't got nothing on me.

      --
      A deep unwavering belief is a sure sign you're missing something...
    17. Re:Amazing! by DragonWriter · · Score: 1

      McNerney seems to be saying that they understood the machine language well enough to simulate the calculator


      Its odd that he would say "disassembled code" if he meant "machine language".
    18. Re:Amazing! by ioshhdflwuegfh · · Score: 1

      I've written an assembler, for x86 no less. MOD/RM and SIB ain't got nothing on me. Oki-doki then. My favorite writing is a 6510 debugger/disassembler (for C64).
    19. Re:Amazing! by mcpublic · · Score: 1

      Barry and Brian Silverman wrote a disassembler, and we all stared at the disassembled code a bunch, then they started running the calculator code in their homebrew simulation of the 4004 and the rest of the calculator hardware. They fiddled with it until they got the printer and keyboard interfaces modeled correctly. The printer serves as the calculator's "heartbeat" in a fundamentally important way. If it "spins" too fast, the calculator stops working. At this point we had a pretty good idea, "from a 10,000 foot level" how the calculator worked, it's overall design, etc.

      What Lajos did was "take it down to sea level." He put tons of time into understanding how the byte code worked, what every single opcode did, what every single 4004 subroutine did, and what algorithms were used to do the computations (e.g. square root). He extensively studied the behavior of the calculator to discover anomalous behavior that made us wonder if there were transcription errors when we read the original ROMs. To see if read the ROMs correctly, we hope one day to compare our results with a working Busicom 141-PF. There are only a couple working ones in existence. We are pretty sure Lajos found one single-bit error, but it doesn't seem to affect the calculator operation in an important way, so we left it. There are other anomalies that, if not intentional, fall into the category of "emergent behavior" like the divide-by-zero you get when you press "=" on a completely cleared calculator. Our simulation is "bug for bug compatible" with the original calculator in this respect. Another example of the analysis Lajos did was to figure out that one of the byte code opcodes was a "branch always." This means there are a few extra arrows on the flowchart diagram that we will want to remove when we get a chance.

  15. I wrote a PC BIOS INT10 video display driver in 4K by Anonymous Coward · · Score: 0

    I wrote a PC BIOS INT10 video display driver in 4KB, with many extensions. That did a whole lot more than some stupid 4-function/print calculator. Whoop-di-do.

  16. Backups? by JustCallMeRich · · Score: 1

    So you are saying that nobody had the source backed up anywhere? We have come so far, yet haven't gone very far at all...

    --
    http://Communityville.com - A free place for new and old neighborhood webmasters to hang out.
  17. 55378008 by Doc+Ruby · · Score: 1

    'leet speak first turned the world upside down as a joke about "BOOBLESS". I wonder if the 4004 could run a softporn text adventure game like that.

    --

    --
    make install -not war

  18. My 4004 Project by cosmicpossum · · Score: 1

    [reminisce] Back in 1972 I did the first uP project at Cornell using a 4004. No assembler, no emulator, not even a PROM programmer. Just a list of op-codes and a sheet of paper that I wrote H or L for every bit of the PROM. That got sent to a electronics distributor that would program the part. Unfortunately, I can't claim to have done the first OPERATING uP project at Cornell! [/reminisce]

    --
    (This sig intentionally left blank)
  19. copyright violation? by Anonymous Coward · · Score: 0


    Our copyright laws discourage information replication, even when the information is no longer profitable and only useful in a trivial sense.

    This is especially evident with software, but also true with other media as well, which fades away when it is not profitable to sell copies and not legal for third parties to re-use or copy freely.

  20. Where's the update? by lseltzer · · Score: 5, Funny

    I found a buffer overflow. Exploit code to follow...

  21. make that 404 by Anonymous Coward · · Score: 0

    New headline: Slashdot recreates the first 404 by slashdotting the website reporting the source code for the first 4004 application.

  22. Did it run linux? by Anonymous Coward · · Score: 0

    Yes, but did it run linux?

  23. large function in small code by Have+Brain+Will+Rent · · Score: 2, Informative

    In 1970 the PDP series from DEC, e.g. PDP-8, had an interpreted (and used interactively) language called FOCAL, arrays (even sparse ones), real numbers, usual math and other functions, for loops, if statements blah blah blah... all the usual stuff - the entire interpreter *and* runtime was programmed in a total of 2K instructions (and they were primitive instructions). That was normal for the time.

    --
    The tyrant will always find a pretext for his tyranny - Aesop
    1. Re:large function in small code by Anonymous Coward · · Score: 0

      4k word PDP8s ran Fortran compilers at that time. You want to know why C originally only allowed 7 character variable names? They just took up too much of the available core store if they were longer.

    2. Re:large function in small code by cburley · · 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 written would have been much easier to write, and perhaps even "smaller" (fewer instructions, maybe fewer bits in the instruction stream?), on the -8, though I confess to remembering too little about the 4004 to be really sure about that. (Of course, the -8 wasn't nearly as nifty a machine, instruction-set-wise, as the -11, or as all-out kick-butt powerful as the -10; I wrote much more assembly/machine code for the -10 than for the other DEC systems combined, and actually got to use -10's far more often, at timesharing companies like Comp/Utility and First Data Corp in Mass. where they ran TOPS-10, and at MIT in the AI lab, where ITS ruled!)

      So, all in all, I think the calculator-on-a-4004 is probably more impressive than FOCAL or BASIC on the -8, though FORTRAN on the -8 probably was no trivial accomplishment. But I haven't looked at the source/assembly/machine codes myself to make a proper assessment.

      (This seems so long ago now. That was around the time a James Bond movie came out with Roger Moore playing Bond. I recall watching it in the theatre, pretty good-sized crowd, and, I think early on in the movie, there's a scene where Bond is in bed and gets some kind of signal or alarm — I forget which — and looks at his watch, which is shown to the viewers and is an early-model LED watch. And I distinctly recall the reaction from the mostly-male audience when he pressed a button on the watch and it lit up with the time in red LED digits: "Ooooooohhhhh!". As it happens, I later became wealthy enough to buy myself a digital watch...but, sadly, not a Lotus Eclipse.)

      --
      Practice random senselessness and act kind of beautiful.
    3. Re:large function in small code by Have+Brain+Will+Rent · · Score: 2, Interesting

      I don't remember the 4004 being all *that* primitive but perhaps I'm thinking of the 8008. But even the 4004 was easier to program than an old Univac machine I used that used patch boards to set up the program - LOL. Regardless I wasn't comparing the relative difficulty between the two machines. I was just making the general observation that people were able to put quite sophisticated software on very primitive machines in what today would be considered microscopic amounts of memory. As for Fortran that actually wasn't that hard to implement on the PDP-8, I was much more impressed with Algol was implemented. IIRC the Algol compiler was user contributed, in the DECUS catalogue, along with a lot of other sophisticated (for the time) user contributed software.

      In fact DECUS may have been the very first organized attempt at general distribution of free and/or open source software.

      --
      The tyrant will always find a pretext for his tyranny - Aesop
    4. Re:large function in small code by FrenchSilk · · Score: 2, Interesting

      And I once wrote a full-featured symbolic assembler in 1579 bytes. Besides symbolic labels, it supported address expressions with +=/* and logical AND/OR, hex and text strings, and a lot more. To the best of my knowledge it is the smallest symbolic assembler ever written. I published and sold it as The Assembler for the VIC-20.

    5. Re:large function in small code by Grant_Watson · · Score: 1

      You want to know why C originally only allowed 7 character variable names? They just took up too much of the available core store if they were longer.

      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.

    6. Re:large function in small code by Anonymous Coward · · Score: 0

      you got balls of steel

    7. Re:large function in small code by cburley · · Score: 1

      Yeah, DECUS was definitely cool. Sorry, I had basically no experience with ALGOL on the -8 or on anything else back then; rarely even saw ALGOL code. (More often saw APL code probably, and that was pretty rare too.)

      (I never had to program patch-board computers easier. Not only would 4004 programming probably be much easier than that, but so would be, I assume, the keypunch-and-submit-as-batch-job programming I "got" to do in Fortran on a mainframe at MIT during high school.)

      --
      Practice random senselessness and act kind of beautiful.
    8. Re:large function in small code by statusbar · · Score: 1

      Fantastic! You should re-publish it for example's sake. Another one I love looking at is Peter Jenning's MicroChess for 6502 which is just a bit over 1 K byte as well.
      --jeffk++

      --
      ipv6 is my vpn
    9. Re:large function in small code by FrenchSilk · · Score: 1

      Umm. Thanks. I guess.

    10. Re:large function in small code by FrenchSilk · · Score: 1

      There is more about it (and me) here.

    11. Re:large function in small code by Ben+Hutchings · · Score: 1

      Right. Some old toolchains had the convention of using exactly 32 bits for each symbol name, with 3 characters in each 16 bits using RADIX50 encoding (where the 50 is octal, meaning 40 decimal). This makes symbol comparison very simple, but of course means symbols must be truncated to 6 characters and case-folded. The C90 standard specifies undefined behaviour for programs using identifiers that would collide under this mapping.

  24. Something is wrong...... by Anonymous Coward · · Score: 0

    Yah I tried out the calculator and something is wrong with it b/c according to it:
    3 + 6 = 0
    5 + 6 = 12
    3 + 4 = .5
    4 + 3 = 12
    9 / 3 = 3
    Somebody messed up somewhere >.>

    1. Re:Something is wrong...... by bpharri2 · · Score: 4, Informative

      Of course if you had bothered to read the article, you'd know that it doesn't work like todays calculators but like the old adding machines:

      "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 = "

    2. Re:Something is wrong...... by Dan+East · · Score: 1

      it doesn't work like todays calculators but like the old adding machines:

      Millions of people still use calculators that behave exactly like that. All financial calculators work like that, and for good reason.

      Dan East

      --
      Better known as 318230.
    3. Re:Something is wrong...... by bpharri2 · · Score: 1

      Wrong choice of words on my part. I meant like today's "standard" calculators, since that is what the 4004 is like and that is what the site talks about for comparison. Of course financial calculators still do it this way with positive/negative cash flows.

  25. vista calc.exe properties by circletimessquare · · Score: 1

    File version 6.0.6000.16386
    Size: 172 KB (176,128 bytes)

    kinda puts things in perspective, doesn't it?

    ah, "progress"

    --
    intellectual property law is philosophically incoherent. it is your moral duty to ignore it or sabotage it
  26. 1024 bytes? Try 1024 bits by davidwr · · Score: 1
    In 1998, to celebrate the 50th anniversary of an early computer, The University of Manchester ran a programming contest on the Baby Mark I, which sported 32 words of 32 bits each and a very limited instruction set: you couldn't even ADD.

    There were, of course, many other ideas apart from those of the prizewinners: programs to compute square roots, fibonnaci sequences, trig functions and encryption algorithms. A program which clears the store totally, another which simulates bellringing. A tamagochi program, a cipher machine simulator, and so on. The winning entry was a noodle-timer program.
    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
  27. Even better by davidwr · · Score: 1

    You can run it in real time!

    --
    Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
  28. I have the original 4004 reference guide by Nefarious+Wheel · · Score: 1
    I have the original 4004 reference guide (blue cover), scored during an early Wescon convention in 1970. I looked at this and said -- "Oooh, a whole hexadecimal digit on a single chip. That's going to change things."

    People used to consider square wave logic charts a programming tool back then, too.

    --
    Do not mock my vision of impractical footwear
  29. Re:I wrote a PC BIOS INT10 video display driver in by bpharri2 · · Score: 1

    And by a whole lot more you mean 4 times more, right?

  30. 80386 or better by scarboni888 · · Score: 1

    You need the protected mode capabilities. Won't even work on a 286 which doesn't have true protected mode.

    1. Re:80386 or better by raynet · · Score: 1

      I recall that at some point people were porting Linux to 8086 but I don't know what happened to that project.

      --
      - Raynet --> .
  31. Somebody call the cops! by breem42 · · Score: 1


    It is obvious this Kintli fellow has violated the DMCA ... or is it the SPCA ... anyway he broke
    the law by reverse engineering a piece of commercially sold software. Since this was not done for
    the purpose of interoperability, the law should be called in!

    --
    If the answer is war, you are asking the wrong question
  32. Asimov's The Feeling of Power by drachenstern · · Score: 3, Interesting

    How has no one mentioned this yet? - Don't blame me too much, I just copied and pasted from: http://downlode.org/Etext/power.html

    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

    --
    2^3 * 31 * 647
  33. Re:Mod Up Interesting! by TheSpoom · · Score: 1

    Wow, I didn't know this was so widespread.

    --
    It's better to vote for what you want and not get it than to vote for what you don't want and get it.
    - E. Debs
  34. 1024 Bytes? Bah! by LS · · Score: 2, Interesting

    How about 256 bytes for a 3D rotating parallax tunnel fly-through !!!

    LS

    --
    There is a fine line between being a cultivated citizen and being someone else's crop. - A. J. Patrick Liszkie
  35. John Titor called...... by Rixel · · Score: 1

    ....and is requesting that you start on the IBM 5100 (the flux capacitor broke).

    --
    Never play chicken with a passive aggressive.
  36. Actually, only 939 bytes of ROM. by noidentity · · Score: 1

    Want to find out how Busicom's Masatoshi Shima compressed an entire four-function, printing calculator into only 1,024 bytes of ROM?

    There were 85 left over bytes at the end (filled with NOP), so it was really only 939 bytes of ROM.

    1. Re:Actually, only 939 bytes of ROM. by Anonymous Coward · · Score: 0

      No, the four-function version of the calculator only required the first four ROMs, 0x000 - 0x3FF in the listing, and used nearly every byte for either 4004 instructions or virtual machine instructions. Another version of the calculator added a square-root key, and pushing that key caused a jump to the 5th ROM which is also in the listing. That's the one that has the NOPs.

  37. and in Vista by peter303 · · Score: 1

    which has this calculator as the core of the calculator accessory, Excel, etc.

  38. Please post this code. by Simonetta · · Score: 2, Interesting

    Thousands of people now and in the future would be interested in studying this code. Please dig up and post this work. Perhaps to one of the 'vintage computer' websites.

        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 to C language as the 32-bit, 128Kbyte memory, 50MHz microcontrollers like the ARM fall below the $5 price.

        But constructing code out of instruction sets one byte at a time is still done for very low-end devices like the Atmel Tiny11 that sells for about $0.30 each. At this price, they can replace 555 timers and TTL gates in updates of classic 1970's and 1980s electronic designs.

    1. Re:Please post this code. by jacquesm · · Score: 1

      sorry for losing track of the conversation for a while... I don't have any stuff from before roughly
      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 than a couple of years with the exception of a saxophone and a couple of books. You sure learn how to not get attached to stuff though :)

      I'll see what I can recover. The funny thing is I still remember a whole bunch of details from the assembly code to this day, I don't think there is other code that I studied that hard. jmp (159) indeed :)

      It is hard for me to see where the value would lie though, unless it is to get a kids version of a computer in a box that you can run under a larger machine. I've given my son a linux machine with "Brandy" on it (a bbc model 'B' basic interpreter for linux) and that seems to serve some of the purposes that I would have for a functioning color computer emulator.

  39. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  40. OS X calculator.app properties by Anonymous Coward · · Score: 0

    In OS X the calculator application is 7.8 MB

  41. Re:Mod Up Interesting! by Anonymous Coward · · Score: 0

    You mean fundementals of floating point?
    http://en.wikipedia.org/wiki/Machine_epsilon