tag 标签: BASIC

相关博文
  • 热度 24
    2014-5-13 18:29
    1394 次阅读|
    1 个评论
    BASIC is that one language that has garnered such bad rap. Edgar Dijkstra and others have famously claimed that a person reared on BASIC was forever damned by the experience. By that reasoning, a baby who dribbles food can never learn table manners, and the old timer who was adept with analog oscilloscopes will be eternally baffled by the new world of the DSO. BASIC got a lot of people into software development. Some shouldn't have gotten involved in that, of course; for others, it seduced them into a career in professional software engineering.   My first programming experiences were not with BASIC. I learned FORTRAN in high school and then moved on to Univac 1108 assembly language before picking up APL, LITHP, and many other languages, including (eventually) BASIC. FORTRAN and assembler suffer from the same lack of structure as the original Dartmouth BASIC, so one would think these languages would also be accused of being injurious to a developer's development. And what could be a bigger blot on the software world than APL?   My first exposure to BASIC was around 1975, when we bought a couple of Altair 8800s. These arguably jump started the personal computer revolution, though they came into being long before the word "PC" existed. Thousands of serious developers and hobbyists bought the machines, often with a paper tape of Bill Gates' BASIC interpreter. It was very liberating to use an interpreter, rather than going through the incredibly painful process of compiling or assembling code. Even today, every little change requires a tedious recompilation. In the 1970s, there were no hard disks on micros; even floppies were expensive and rare. Recompiling to paper tape or cassette decks ate enormous blocks of time. With BASIC, one could type in a line of code and then "RUN". The edit/test cycle took seconds.   BASIC was the lingua franca of the eight-bit computer world. All the machines sold in the late 1970s and early 1980s supported it, and in many cases, it was built into the ROM chips. Often there was no OS; the machine booted to a BASIC interpreter. Even the vaunted IBM PC originally had the language in ROM.   Embedded development in the early days was almost always in assembly language, and I suspect there wasn't a manager on the planet who was happy about the low productivity it entailed and the completely cryptic end product that only a pony-tailed engineer who never came in before noon could understand. A lot of people were looking for alternatives. A few C compilers (e.g., MANX C) were available in the early 1980s, but it was not a popular language among eight-bit developers. Everyone was doing it Everyone knew BASIC, so in 1983, I wrote a BASIC compiler (not interpreter) targeted at embedded applications. It was interactive and felt exactly like an interpreter; one entered code with line numbers. "RUN" compiled and started executing the code in less than a second. The compiler generated very tight code and even had built-in multitasking support. It ran under CP/M on 8080 and Z80 systems and comprised about 30,000 lines of assembly language. Multitasking meant all generated code and libraries had to be reentrant, so I hired a college kid to write a reentrant and position-independent floating point package -- quite an accomplishment, given the 8080's architecture.   Surprisingly, it took off. Orders showed up and then steamrolled in. It was startling to find checks from people I didn't know in the daily mail. I was working out of a bedroom in the house, but I couldn't handle the order fulfillment, so my wife quit her job to help. Eventually, we moved into the basement, because the upper two floors were filled with manuals, boxes, floppy disks, and (eventually) employees. Later we rented space in an RD park and set up more professional offices.   IBM stunned the market when it introduced its PC. I bought one outfitted with everything -- two floppy disks, 128 KB of RAM, etc. -- which cost $7,000. Customers were asking for a PC version of the compiler, so I purchased a Z80 to 8088 assembly translator, which created awful, nasty code because the instruction sets were so dissimilar, and, of course, all the code generation was incompatible. In a hectic couple of months, I recoded it in 8088 assembly. If you had anything for a PC then, it sold, and our BASIC profited from that frenzy. It didn't hurt that Jerry Pournelle was an early advocate who featured it in Byte Magazine.   Code generated by the compiler eventually was used at both poles for research instruments, aboard the space shuttle, and even in the nuclear submarine fleet. But embedded C started to gain adherents, and BASIC's demise was evident. The last updates were in 1988, but to this day I still get requests for new versions.   I read an awful lot of code our customers wrote in BASIC. Some was pretty terrible, but a lot was as carefully crafted as anything written in C today, within the constraints of the language, giving lie to the belief that BASIC makes for crummy developers. I'll bet a lot of readers got their start in computers with BASIC but today build world-class code.   What was your experience with BASIC? Do you feel it poisoned your abilities?
  • 热度 20
    2012-5-25 13:06
    2160 次阅读|
    0 个评论
    According to the Phrase Finder , the concept of tickling pink is of enjoyment great enough to make the recipient glow with pleasure, which pretty much describes my current state of being. I just received the most amazing email... but before we go there, in order to set the scene, I need to explain that a couple of years ago my chum Alvin and I wrote a book called How Computers Do Math . (May I be so bold as to note that this little rascal, which has 4.9 stars out of 5.0 on Amazon, would make an ideal gift for anyone who wants to know more about how computers perform their magic.) Accompanying the book is a virtual 8bit microprocessor. The interface to this virtual machine is a calculator front panel as illustrated below (the reason some of the buttons are blank is that you can configure them to have whatever annotations you wish).   When you first power-up this little scamp, whose official name is the DIY Calculator (DIY stands for "Do-It-Yourself") nothing happens... The idea is that the book guides the reader via a suite of step-by-step labs to create a program in assembly language that makes our virtual microprocessor and calculator front panel function as a simple four-function calculator. But the possibilities are limitless – someone has already created a BASIC interpreter (in our assembly language, of course), and I have plans to create a simple C Compiler (again in our assembly language)... one day. OK, one more thing before we proceed to the reason for this column is that – as part of the DIY Calculator project – we also created something called The Official DIY Calculator Data Book (you can access both the DIY Calculator software and this Data Book for FREE from the Downloads page of our www.DIYCalculator.com website). This data book was modeled on the old microprocessor data books of the late 1970s. It basically tells you everything you need to know to build your own 8bit microprocessor from the ground up. All of which leads us to the following message, which I just received from John R. Wind: Hello Mr. Maxfield. If you don't mind, I thought I would tell you about a project of mine that implements your "DIY Calculator" in a digital logic simulation program called Logisim (Website – http://ozark.hendrix.edu/~burch/logisim/ ). I am an Electrical Engineer from Grand Rapids, Michigan, and I found Logisim on the internet one night. It is a nice little cross-platform program that I can carry about on a thumb drive and work on projects when I am bored. Now all I needed was a project. There are many digital devices built into Logisim, but one thing lacking was a CPU. After searching around for a premade CPU, I found that a lot of college-level computer classes ask students build a CPU in Logisim as classwork. So I thought that sounded like fun. In looking for information about CPU design, I came across your "DIY Calculator" website. The descriptions in the "Official DIY Calculator Data Book" were just what I needed to get started. Much of the design is a straight forward implementation of your descriptions. Coming up with the Instruction Decoding and Sequencing control logic myself was enough of a challenge to make it interesting. Logisim is very hierarchical and lets you define sub-circuits that you can assemble to make larger constructs. This feature was used to greatly help in organizing the design. Now that I have your virtual CPU built out of digital logic components, I can use it as a sub-circuit to build larger projects with. As an example, I have built a keypad and display that faithfully emulate your "DIY Calculator" and are connected to your virtual CPU along with some memory in the RAM and ROM configuration described in your book. This setup is serving as my "test bed" because it is 100% compatible with all of the programs from your book "How Computers Do Math". Currently, I am trying them out to see if any glaring bugs in my design pop up. Depending upon the computer running Logisim, the virtual CPU is no speed demon. The fun for me is in getting the assembly code to work, not in using the result.   The DIY Calculator running in Logisim   Logisim is very graphically oriented, and it is very educational to look into the design of the CPU and watch how the program is being executed as you step through it. When satisfied, I intend to make my design available to others on the Internet. I thought you might appreciate this because, in a sense, you have provided all of the documentation. If asked for information on the little CPU, I will just refer others to your book. :-) This was all just a warm up. Back when I was a high school student, I built a microcomputer out of a kit that used the RCA 1802 Cosmac Elf microprocessor. I think next that I may relive my youth by designing an 1802 CPU in Logisim and re-building (in a virtual fashion) the microcomputer I once had. There is something satisfying about going myself one better by having to build the CPU itself first. Cheers, John R. Wind PS Just FYI, the display in the image above is saying "Hello World" because it is running that program from your book :-) Wow! Color me impressed. I immediately emailed John back and we bounced a few messages back and forth. John very kindly provided a copy of the Logisim version of the DIY Calculator for anyone to play with if they want ( Click Here to download it in the form of a ZIP file – of course you will also need to download Logisim itself from the website noted in John's message). But wait, there's more, because John kindly said I could share his email ( jrwind@comcast.net ) so that anyone who does play with his Logisim version of the DIY Calculator can contact him with comments and suggestions. The end result is that, as I noted in the title of this column, I am "Tickled Pink". I cannot even begin to describe the countless hours I spent creating the diagrams and text in How Computers Do Math and in The Official DIY Calculator Data Book , so knowing that someone has used this work to the level that John has it very, very gratifying. I think I will have a warm glow for a long time to come...  
相关资源