Michael J. Mahon wrote:
Knut Roll-Lund wrote:Paul Schlyter wrote:In article <Pine.LNX.4.64.0610240911200.32311@dosius.ath.cx>, Lyrical Nanoha <lyricalnanoha@dosius.ath.cx> wrote:On Tue, 24 Oct 2006, Paul Schlyter wrote:Also, since Applesoft has no integer arithmetic (all arithmetic is done in floating-point in Applesoft), there isn't much you can inline when compiling Applesoft to 6502 machine code -- unless you want a REALLY bloated Applesoft program, where each and every arithmetic operation would take some 500 bytes of machine code! With such bloated code, you wouldn't be able to do much within 48K of memory.I thought fpbasic had the % variable type (16-bit signed integer)? -uso.Yes, it does. But Applesoft does execute this line: 10 A% = B% + C% as: Load integer B%, convert to floating point Convert integer C% to floating point, add it Convert the sum to integer and store in A% Having integer variables is NOT the same as having integer arithmetic. If you try MBASIC under Apple CP/M; you'll notice a difference. That interpreter has integer arithmetic as distinct from floating-point arithmetic. Under MBASIC, the statement 10 A% = 1% + 2% will execute significantly faster than 10 A% = 1.0 + 2.0 and if you compile your MBASIC program with BASIC COMPILER, the former will execute hundreds of times faster than the latter (the former will be compiled to inline code for an integer addition, while the latter will compile to a subroutin calls for floating-point addition). So Applesoft do have integer variables, but no integer arithmetic. And the operation 30000 * 10 won't overflow, because it is performed in floating-point arithmetic. In MBASIC, the operation 30000% * 10% *will* overflow !!!!I'm surprised, on the TRS-80 which also has Microsoft basic, though a bit differently looking, does integer operations on integers (and it is an important point to use integers for speed). This is so except for division where the actual division is done in single precision. Even constants are done as integers as long as they fit.In Applesoft, constants are represented in ASCII in the program text and converted on each use. This is why assigning a frequently used constant to a variable speeds up a program.
Yes A=1:B=A is faster than A=1:B=1 this is similar, constants are stored as ascii also on a TRS-80, but when converted they start out as integers and will convert to single or double precision as needed. Line numbers after THEN, ELSE, GOTO or GOSUB are also stored as ASCII but the line numbers themselves (at the beginning of a line) is stored digitally 16 bit.
I have a basic compiler for the TRS-80 that does a strange hybrid thing; ACCEL2. I bought it back in the old days. It will put assembly into comments within the basic program and there is a small runtime library too. It will compile only what is advantageous. The output is smaller and a lot faster.
The Microsoft basic came with the TRS-80 (Model I) Level II that came in August 1978. The original TRS-80 Microcomputer (Model I Level I) from August 1977 had a basic that was made by Tandy famous for its error messages: 3 in all WHAT?, HOW? and SORRY (means syntaxerr, outofrange and outofmemory respectively). :-)In the tradition of the JOSS language for the Johnniac computer at RAND, which had exactly one error message: Eh?
So it is not unique :-)I write software and identifying and then explaining to the user and/or log what went wrong is so much tedious work. But of course I benefit from it too getting less phone calls from frustrated users, or can at least identify what is wrong so I can help them.
-- Knut (delete 'nogarbage.' for email)