Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
Programming Links The Internet IT Technology

A TCP/IP Stack and Web Server In BASIC 251

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.
This discussion has been archived. No new comments can be posted.

A TCP/IP Stack and Web Server In BASIC

Comments Filter:
  • by ultrapenguin ( 2643 ) on Saturday August 16, 2003 @09:35AM (#6711947)
    NetRange: 169.254.0.0 - 169.254.255.255
    is one of those "non-routable private IP address spaces".

    RTFRFC
  • Re:What? (Score:1, Informative)

    by waitigetit ( 691345 ) on Saturday August 16, 2003 @09:44AM (#6711980)
    No it booted right into the basic interpreter of the BIOS
  • Re:What? (Score:1, Informative)

    by Anonymous Coward on Saturday August 16, 2003 @09:50AM (#6711999)
    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.
  • by i_really_dont_care ( 687272 ) on Saturday August 16, 2003 @10:03AM (#6712048)
    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.
  • Re:Slow (Score:0, Informative)

    by brrrrrrt ( 628665 ) on Saturday August 16, 2003 @10:07AM (#6712066)
    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.
  • data statements (Score:5, Informative)

    by magarity ( 164372 ) on Saturday August 16, 2003 @10:12AM (#6712086)
    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.
  • by henrik ( 98 ) on Saturday August 16, 2003 @10:34AM (#6712172)
    You don't need any copyright notice. You always own the rights to your original work no matter what.
  • Not new (Score:4, Informative)

    by wumpus188 ( 657540 ) on Saturday August 16, 2003 @10:43AM (#6712217)
    Actually, Parallax [parallax.com] 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... :)
  • Re:Slow (Score:1, Informative)

    by Anonymous Coward on Saturday August 16, 2003 @10:44AM (#6712223)
    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.
  • Re:Oh good... (Score:2, Informative)

    by AndroidCat ( 229562 ) on Saturday August 16, 2003 @10:47AM (#6712234) Homepage
    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.

  • R *this* FRFC. (Score:5, Informative)

    by L. J. Beauregard ( 111334 ) on Saturday August 16, 2003 @11:42AM (#6712446)
    There are more special IP ranges than the private network ranges in RFC 1918. They are documented in RFC 3330 [ietf.org]. 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.
  • by yellowstone ( 62484 ) on Saturday August 16, 2003 @11:43AM (#6712448) Homepage Journal
    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. ;-)
  • by Arker ( 91948 ) on Saturday August 16, 2003 @12:52PM (#6712773) Homepage

    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.

  • Re:Cowabunga! Nope! (Score:3, Informative)

    by UncleRoger ( 9456 ) on Saturday August 16, 2003 @12:57PM (#6712801) Homepage

    Somebody needs to attend the Vintage Computer Festival [vintage.org]! 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.

  • Why so "impossible"? (Score:2, Informative)

    by ant_slayer ( 516684 ) on Saturday August 16, 2003 @01:07PM (#6712852)

    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-

  • by at_18 ( 224304 ) on Saturday August 16, 2003 @02:32PM (#6713254) Journal
    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....
  • by McDutchie ( 151611 ) on Saturday August 16, 2003 @02:41PM (#6713289) Homepage
    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!

He has not acquired a fortune; the fortune has acquired him. -- Bion

Working...