39

Except for the very earliest versions of basic, LET was rarely used, but the LET keyword was not always optional. Early BASIC interpreters required it; however, for most versions that came out for the PC (including Microsoft BASIC), the use of LET was optional. Later standards in BASIC often required that the keyword be supported, but since there was no ...


26

Internally, a BASIC program isn't represented as the text you see when you list it, but as a tokenized data structure where each of the language keywords are represented in an optimized 1-character form. Basically, if the upper bit is set in a character byte (i.e. values >= 128/$80), it is processed as a token. Note that this does not only apply to the ...


25

It is well established that Microsoft's 6502 BASIC (and Commodore BASIC is just a manufacturer specific adaption) is a port of the original 8080 BASIC done for the Altair -- alas, not a direct one, as the prior port to 6800 was used as code base (*1). The creation is attributed (in its source code) to three programmers: Bill Gates for the execution code (...


18

I can only answer to the first question: the LET statement was actually used in 48K Sinclair BASIC, in which due to the way commands are entered, a keyword is needed before an identifier can be typed, so LET was needed in order to write a variable assignment (although there were unofficial patches to the ROM that eliminated that requirement). In fact, and ...


15

What I don't understand is why this quirk exists and how it works. As usual, lousy programming. It's a routine that exists in next to every Microsoft Basic, but often modified by the receiving company. It's used to list a line. On the 6502 version space was a premium, so they tried to cut down as much as possible in tests. And lets be serious, a 'real' ...


13

I've seen a number of articles, such as this one which states it was based on 8080 BASIC, and this one which states that 8080 BASIC was first ported to the 6800, which was translated to the 6502. It would make sense to take the methods used in 8080 BASIC and use them on other processors.


13

Yes, Z-80 instructions were used in Microsoft's Z-80 BASIC. For example, look at the TRS-80 Model I or Model III ROM BASIC and you'll find a relative jump JR NZ,0x871 at location 0x88E. The 8080 does not have relative jump instructions. That instruction is part of a routine to shift CDEB right by L bits which is used by the floating point code. Do a ...


13

If you mean if Microsoft BASIC's core ever used Z80 instructions at all, then I would say no - the code of BASIC is designed using 8080 compatible instructions, and all "drivers" are created as appropriate for the platform. It may happens that some vendors have modified the code to Z80 in order to "compress" it and free some space for special functions, but ...


12

The two statement forms are slightly different in meaning. The meaning of NEXT is, roughly, "increment the loop variable for the most nested loop and go to the next iteration of the loop". The meaning of NEXT I is, roughly, "while the mentioned variable is not the loop variable for the most nested loop, abandon execution of that loop, then perform as NEXT"...


11

My memory is that the O/S (for want of a better name) occupied the lowest memory followed by the code of your Basic program. Variables were allocated at the highest available address. So, as you wrote longer programs and used more variables, the two converged in the middle You're right - well, BASICly (SCNR). I don't recall any protection, Yes, there is....


10

The files are encoded as follows: the first byte is 0xFE to indicate that it’s a protected tokenized file (0xFF for a regular tokenized file); the remainder of the file is encoded using exclusive-ors with two keys, embedded in the interpreter (or in the ROM, for BASICA). The two keys are Key1 db 9Ah, 0F7h, 19h, 83h, 24h, 63h, 43h, 83h, 75h, 0CDh, ...


10

The following article details some of the early history of Commodore BASIC (including other Microsoft BASIC 6502 versions), particularly v1 and v2. Create your own Version of Microsoft BASIC for 6502 Originally, Commodore paid a flat fee for Microsoft's BASIC, instead of a royalty license, reportedly because Jack Tramiel told Bill Gates, "I'm already ...


9

And I found the answer only moments later when I came across the original manual. The difference is that the 4k version (mainly) did not have strings (!!), lacked a number of math functions (ATN, etc), logical operators (AND, OR) and PEEK/POKE. UPDATES: And a short form of the differences can be found in the original MITS brochure. Although no specifics ...


9

Your initial interpretation was correct -- Microsoft Basic is storing the address of the first statement of the FOR/NEXT loop. But it is also storing the line number of the first statement. See the comment at the top of flow1.s: ; ---------------------------------------------------------------------------- ; "FOR" STATEMENT ; ; FOR PUSHES 18 BYTES ON THE ...


7

Bill Gates and/or Paul Allen likely did not write the 6502 version of Basic. Marc McDonald, one of the very first Microsoft employees, is reported (on the Wikipedia page for Applesoft BASIC, for instance) as having written the 6502 version of Microsoft Basic. But he would have had access to all the source code to Gates and Allen's 8080 BASIC, as well as the ...


7

Monte Davidoff's floating point routines for early Microsoft BASIC used Chebyshev Modified Taylor series for EXP(x). There's a very helpful disassembly of the TRS-80 MC-10 ROM here: http://www.roust-it.dk/coco/mc10/romlist.txt. It's 6800 assembly, and the whole commented routine (using the same constants) is: TBLF59B FCB $81,$38,$AA,$3B,$29 ;1.44269504 (...


6

What protection there was depended on whose BASIC interpreter you were running. Applesoft BASIC had a check surrounding most things that pushed the limits of what had been allocated and would trigger an OUT OF MEMORY error if there was going to be a collision. You can see this in action in the source code by looking at the code preceding jumps to MEMERR ...


5

Rosetta code has a category dedicated to programs written in Basic: http://rosettacode.org/wiki/Category:BASIC


5

GW-BASIC 3.23 gave an error, "Overflow":


5

I honestly don't remember these structures when I ran BASIC-PLUS on RSTS/E, so I never used them. I did, however, use them pretty heavily when I moved to BASIC-PLUS on the VAX. I loved BASIC-PLUS on the VAX. We used it mostly with its first class integration with RMS. My singular complaint at the time was its reliance on line numbers for ON ERROR GOTO, even ...


4

As for "branch and loop like in-line operators are a waste, because they can be emulated with mutiple lines": It's important to remember that on machines like the PDP-11, a user was restricted to 64 KB or less, and it wasn't particularly fast. And if you have a larger scientific program that needs lots of memory for matrices and arrays, you'll notice the ...


4

Those programs aren't BASIC*. Detokeninzing them with petcat produces: $ petcat bez\ milosti-inst.prg ;bez milosti-inst.prg ==0801== 1991 sys2065 tmc $ petcat bez\ milosti.prg ;bez milosti.prg ==0801== 1987 sys2065 fbg So each of those prg files contains only one line of BASIC code: a sys instruction that jumps into the machine code part of the ...


4

A typical MS-BASIC interpreter would allow configuration of two key addresses: the start and end of the memory space it was allowed to use. The tokenized BASIC program was always expected to start one byte after the bottom address. The interpreter would then maintain and update a few additional addresses: The end of the BASIC program text and start of ...


4

They expanded the variable table. Each entry starts with a type byte followed immediately by the full variable name. This is based on an analysis of the Microsoft BASIC-80 5.2 source code found here. The core of the interpreter is BINTRP.MAC, which has most of the definitions used here. This includes NAMCNT (one byte) and NAMBUF (NAMLEN - 2 bytes), which ...


2

Using "qbasic source archive" as a search turns up some potentially-useful links, including: 48 files found in Library "Basic/QBasic Programming" Also includes files to do with PowerBasic. From a brief scan, the files seem to be more utility orientated (i.e. extending Quick/Power-basic) than pure source examples. 134 files found in Library "Basic And ...


2

Later versions of BBC BASIC (V and VI on the Acorn Archimedes/RiscPC) have structured-programming constructs which, syntactically, look a lot like some of your examples. For example, the following is legal: WHILE A <> 10 : A += 1 : ENDWHILE However, a construct like A += 1 WHILE A <> 10 would potentially be faster than the above while-loop. ...


2

There are a lot of vintage computer books (and magazines with type-in BASIC listings) for a variety of versions of BASIC on Archive.org which are available in a variety of formats including text. Search for BASIC books for any computers which had Microsoft BASIC in ROM. Here is the link to the text version of David Ahl's "More BASIC Computer Games" on ...


2

I never spent much time using MS BASIC like the commodore systems, but for the Sinclair systems I'm most familiar with your description is essentially correct, except that I believe variables were stored immediately after the program and were moved whenever the program length changed. The machine code stack was at the top of memory (growing down from an ...


2

Yes, Microsoft 6502 BASIC was clearly a port of their 8080 BASIC. Unfortunately the original 8080 source code for Microsoft BASIC isn't easily available, so we can't compare it directly to that without going to the Harvard University library to read the paper copy. But the Microsoft source code for a later version of their 8080 BASIC, BASIC-80 5.2 (...


2

Does anyone know why? I imagine that not having to read the I would help a tiny bit, but the time difference seemed far too great to be that alone. Short Answer: It's quite simple. Looking for a NEXT stack entry with a specific variable takes more time then just looking up the last NEXT- and beingpart of a loop makes it even more costly. Detailed Answer: ...


Only top voted, non community-wiki answers of a minimum length are eligible