Slashdot Mirror


A TCP/IP Stack and Web Server In BASIC

A writes "Back in the day, a BASIC interpreter was standard on every home computer system and everyone had to know at least a little BASIC to be able to use their computer. But who would have thought that you could write some serious networking code in BASIC over 20 years later? Just a few days ago, Lee Davison released the BASIC source code for his 6502-based Ethernet web server. The web server runs under his EhBASIC interpreter on the 1 MHz 6502 CPU and is able to blast out web pages at an amazing speed of 20-35 seconds per page!" Sure, it's not really practical, but I give it cool points.

17 of 251 comments (clear)

  1. Re:Down in three seconds flat by ultrapenguin · · Score: 5, Informative

    NetRange: 169.254.0.0 - 169.254.255.255
    is one of those "non-routable private IP address spaces".

    RTFRFC

  2. Re:What? by waitigetit · · Score: 1, Informative

    No it booted right into the basic interpreter of the BIOS

    --
    I could care less, but not without a lobotomy
  3. Re:What? by Anonymous Coward · · Score: 1, Informative

    What days? CAMMOROMU 64 days. When you switched the power on to Commodore C64 all you got was the basic interpreter.

    But already in 1984 was introduced SHARP MZ-821 that only had assembler monitor. You had to load Basic if you didn't want to write Assembly programs.

    Cammoromu C64 was bad because the build in Basic hogged memory of course. With Sharp you had all the 64 kilobytes to yourself.

  4. Not really that uncommon by i_really_dont_care · · Score: 2, Informative

    A lot of microcontrollers can be programmed in Basic-like languages. It's easy to write basic interpreters/compilers because of the limited features of the language. Remember that "pure" basic doesn't have a subroutine concept at all (besides the very limited GOSUB), and no local variables. Commercial PLC systems have been using Basic as the "high-level"-language of choice for ages. Though they are now more and more moving to IEC-61131-compatible languages like ST ("structured text") and graphical languages.

  5. Re:Slow by brrrrrrt · · Score: 0, Informative

    I'm not sure now if the 6502 was only inwardly 8 bits, but outwardly 4. But I know it ran at a little over 1 Mhz, so with a comparatively huge interpreted basic program running on it, I can see why it's slow.

  6. data statements by magarity · · Score: 5, Informative

    It's the chuncking through those data statements at the end that helps really beats up performance. Defining all those as strings at the beginning will ameliorate that problem.

  7. Re:Source code has no copyright notice by henrik · · Score: 2, Informative

    You don't need any copyright notice. You always own the rights to your original work no matter what.

  8. Not new by wumpus188 · · Score: 4, Informative

    Actually, Parallax was doing this since what... 1992? They got TCP/IP stack for their BasicStamps too. But of course, their stuff runs a bit faster than 1MHz... :)

  9. Re:Slow by Anonymous Coward · · Score: 1, Informative

    How can someone's bad memory-musings be modded informative? A simple Google will reveal the 6502 is indeed an 8 bit CPU with an 8 bit bus. Sheesh.

  10. Re:Oh good... by AndroidCat · · Score: 2, Informative
    You might want to do a search on "Tiny Basic". After BillG wrote his snooty anti-piracy letter way back when, some of the first open source projects were a number of Tiny Basic interpreters. (It's how Dr. Dobb's got its start.)

    They were slow and limited, but playing with them and extending them was a great way to learn. After those came the Small C compilers--never looked back.

    --
    One line blog. I hear that they're called Twitters now.
  11. R *this* FRFC. by L.+J.+Beauregard · · Score: 4, Informative
    There are more special IP ranges than the private network ranges in RFC 1918. They are documented in RFC 3330. The one in question is:

    169.254.0.0/16 - This is the "link local" block. It is allocated for communication between hosts on a single link. Hosts obtain these addresses by auto-configuration, such as when a DHCP server may not be found.
    --
    Ooh, moderator points! Five more idjits go to Minus One Hell!
    Delendae sunt RIAA, MPAA et Windoze
  12. Re:Looks more like assembler to me... by yellowstone · · Score: 4, Informative
    Variable names limited to two characters

    What BASIC had that limitation? Surely none that I ever used as a kid (mid 80s).

    The BASIC on the Commodore C64/C128 did. The BASIC on the TI-99/4 did. The BASIC on the PDP-11/45 where I first programmed did by default (you could issue an EXTEND keyword to allow longer identifiers -- back then I didn't see why you'd want to bother with all that typing...)

    (mid 80s).
    Newb. ;-)
    --
    150 Opening BINARY mode data connection for slashdot.sig (129323052 bytes).
  13. Re:Looks more like assembler to me... by Arker · · Score: 2, Informative

    Obviously you aren't an old-school BASIC guy. That's how it worked. If you wanted to do anything fast, you wound up rolling a bunch of machine language inside a BASIC control loop.

    --
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-
    Friends don't let friends enable ecmascript.
  14. Re:Cowabunga! Nope! by UncleRoger · · Score: 2, Informative

    Somebody needs to attend the Vintage Computer Festival! The TRS-80 Model I, II, III, 4, et al used the Z-80, not the 6502. Unless you mean the Color Computer, which (iirc) used the 6809. There was another one (Model 6000?) that used the 68000, iirc. But no 6502's.

    --
    Stupid people will be persecuted to the fullest extent allowed by law.
  15. Why so "impossible"? by ant_slayer · · Score: 2, Informative

    Okay, I recognize the value of doing this (as a hobbyist myself). The fortitude required to accomplish such a feat is noteworthy. However, I have noticed a strange trend in these kinds of posts on Slashdot. Why do so many people respond with comments like, "I didn't know it could be done!"?.

    Technically, all of these languages are mathematically reducible to Turing machines. Thus, they are all *technically* able to perform the same tasks (ok, sure, you might have to extend your interpreter/compiler to handle things like syscalls, but hey, it's within the scope of reasonability). We could effectively use any programming language to produce any program. If the first web server is written in C, then by mathematical extension, we know that it could also be written in Perl, Forth, Fortran, and even BASIC. The difference is just that it might be a royal pain.

    I don't mean to denigrate the work this guy did -- in fact I'm amazed that he did it. But I'm not amazed *that it's possible*.

    What should elicit such responses? If the guy wrote a web server in HTML (a markup language). That is theoretically impossible. There are all kinds of languages that are not reducible to Turing machines -- make a web server using nothing but regular expressions and *I'll* say "Wow, I didn't know that was possible!"

    -Josh O-

  16. Re:Looks more like assembler to me... by at_18 · · Score: 2, Informative

    Is that why all loops in any language in any source code seem to use i and j?

    No, it's because in early Fortran compilers integer variables were letters from I to N (because they are INteger, see?).

    So, in Fortran you would start a loop using the first available integer variable, i, and then j, k and so on.

    How that was carried on to other languages is a mystery....

  17. Re:Looks more like assembler to me... by McDutchie · · Score: 4, Informative
    Old-skool BASIC was really heinous:

    * Variable names limited to two characters
    This restriction was not universal, it depended on the dialect (there was, and is, no such thing as a standardized BASIC language).
    * Only data types are integers and strings
    I'm pretty sure that all variants had floating point data types as well.
    * No structured data types, only (fixed size) arrays
    But you could DIM them dynamically using a variable.
    * No names in control flow, just GOTO 100 and GOSUB 9000. No parameters for subroutines.
    Mostly true, but control flow was a bit better than that: there was also ON X GOTO 10,20,50,80 (which would go to line 10 if X=1, line 20 if X=2, etc) as well as ON X GOSUB in the same way.

    Also, there were user-defined one-line functions with parameters, which could even be recursive, as in: DEF FNX(P1,P2)=Y where X is the function name, P1 and P2 are parameters and Y is an expression.
    * Plus, it was typically interpreted, for extra slowness at run time.
    No argument there!