Basic V2 rocks

Microsoft has released Basic V1.1, which is the same source code of the BasicV2 used in a lot of Commodore 8bit computers. Microsoft Basic was a huge success: Microsoft managed to create a configurable version of the it for dozen of microcomputers.
BasicV2 was so solid Commodore used also for Vic20 and C/64 (the code is re-compiled to different memory areas, but it is the same). Despite the tiny version number, Microsoft Basic spots a lot of features like
- 2-letter variables (but you may add more characters for better coding)
- Full fledged floating-point arithmetic
- User-programmable function (DEF FN)
- Dynamic string allocation via a ‘Garbage Collector’
- Subroutines (GOSUB/RETURN) and common control structures (for loops, IF… pure spaghetti code!)
- Random number generator, and minimal time management via special TI variable
- Data instruction to store binary data easily
- Ability to use “abbreviated commands input” which was quite handy to input programs.
- Machine language support in form of SYS,WAIT, PEEK and POKE.
- REMarks…. for comment insertion (whooooa): every time you fail to comment your json inputs, you will miss REM command, believe me!
Please keep in mind this is a pure-assembly program, a way harder to code than a i.e. python program! Neverless Basic V2 was unable to do graphic or sound out of the box, and Commodore code often needed to do plenty of obscure instructions like peek and poke to just show tiny sprites on the screen
What Microsoft forget to say is how the dealing was done with Commodore… it was one of the rare occasion in which Commodore CEO (Tramiel) was able to get a huge discount:
The core is based on 6502 Microsoft BASIC, and as such it shares many characteristics with other 6502 BASICs of the time, such as Applesoft BASIC. Commodore licensed BASIC from Microsoft in 1977 on a “pay once, no royalties” basis after Jack Tramiel turned down Bill Gates’ offer of a $3 per unit fee, stating, “I’m already married,” and would pay no more than $25,000 for a perpetual license. 1
If you consider how much Commodore computers would be sold, this was a stellar deal for Commodore because it avoided paying royalties for every unit sold!
For a complete story of 8bit computers, please refer to my 8bit computers opera
CHRGET
MOS 6502 is a true orthogonal 8-bit system, with only three internal registers (A,X,Y) with different purposes, able only to do sums and subtractions (no fancy multiplication). This design lead to a very fast chip: most of the instructions take 2-3 cycle, with more cycles for the complex indirect instructions: 6502 delivered very high throughput, compared to other chips of its era (like Z80).
As we shall see, one of the downside of the 6502 is the lack of a true way of addressing an indirect location inside its 16bit-space: you are unable to create a real “pointer”, and you are limited only to 256 bytes offset from a “baseline” address. To overcome this limitation, self-modifying code was the norm, like the CHRGET routine in the C/64 BASIC V2.
You can study CHRGET in the microsoft code, and the C/64 implementation is described at C64 Wiki 2.