Hot answers tagged

59

Your mention of TRS-80 provides a clue. In the TRS-80 character set, the space normally occupied by the ASCII [ character is instead a ↑ (up arrow) character. Old versions of BASIC (such as this one from 1964) use the up arrow character to indicate exponentiation, probably because at that time the ^ character was not even in the ASCII standard. (There is ...


52

The difference between Applesoft BASIC and the other Microsoft 6502 BASIC derivatives can be explained by the fact that Applesoft BASIC was not the first BASIC for the Apple II; the first was Apple II Integer BASIC, in turn derived from Apple I BASIC, which had been independently created by The Woz. Integer BASIC supported only 16-Bit signed integers as a ...


45

BBC BASIC, first shipped in 1981, includes the EVAL keyword, which means "ask the interpreter to evaluate this string as an expression". Since strings can be mutated, a program can mutate what will be evaluated at runtime. The BBC MOS also provides *SPOOL (write screen output to a file) and *EXEC (read text from a file and act as if it had been typed), if ...


44

Yes, BASIC is much slower than assembly for many operations. For an easy example, try out this program on a Commodore 64 or emulator: for i = 1024 to 1984 : poke i,peek(i) or 128 : next You will see each character on the screen reverse, row by row, over the course of ten seconds. By contrast, the exact same routine in machine language inverts the entire ...


43

[W]ere these interpreters implemented as tree-walker interpreters or bytecode interpreters? Neither, or both. They are kind of source code interpreters - much like (classic) shell scripts - except they used a tokenized storage format (*1). Their structure was dictated by balancing lack of memory, lack of interpreter code and desired optimization for speed (*...


37

In old computer books of cheaper sort, (Paperback or pocket books) it was quite common that they couldn't type set all special characters directly. Either they did as in this case, changed the character for something the computer in question didn't use, but the type setter could handle. In this case this is normally mentioned in the foreword of the book. ...


25

It is the exponentiation operator. Why is that? On a TRS-80 Model III the line of BASIC entered would literally be: LET Z1 = M * D1 * (PQ / A) [ 3 To get the [ character you would press the up arrow key. You would press the same up arrow key on its predecessor, the TRS-80 Model I. However, it would display as: LET Z1 = M * D1 * (PQ / A) ↑ 3 This is ...


23

The big improvement to the language in Locomotive BASIC, compared to Sinclair BASIC (and many other BASICs), was the addition of timer support: AFTER 50,0 GOSUB 320 would call the subroutine at line 320 after a second, and EVERY 500,0 GOSUB 320 would call the subroutine every ten seconds. In both cases, the first value is the interval in fiftieths of a ...


22

The answer is pretty straightforward: 65535 is for BASICs, which can handle number lines as an unsigned integer (2 bytes wide) BASICs, which handles two-byte integers as "signed", usually have the line number limit 32767 (highest positive number). Those BASICs often have the "negative addresses" for POKEs and PEEKs, i.e. "POKE -1247,10" etc. Sinclair ZX ...


21

Was Locomotive BASIC significantly better than Sinclair BASIC? TL;DR: Oh, yes, it was! I'm aware that both Basics were more advanced than the C64 Microsoft implementation, Comparison of C64 BASIC to other BASICs of the same time is never in favour for the C64, as it's a quick port of the original 1977 PET Version. but neither [Locomotive BASIC, ...


20

Given that HP’s Rocky Mountain BASIC could load and run parts of code from disk, and given those parts of code could be plain text and the files could also be saved on the fly, I would say yes it should be possible. I don’t know if anyone tried to do that with RMB though. There were definitely self modifying programs using peek and poke but of course your ...


20

With so many different implementations of BASIC a comprehensive answer is difficult. So here's the limits for TRS-80 Model I and III BASIC (written by Microsoft). Line numbers are stored as a two byte word but the largest allowed by the input routines is 65529. Primarily because this is an easier limit to test rather than checking for overflow. The line ...


19

In Commodore BASIC (used in the PET, VIC20, C64, C16, Plus/4, and C128) which is derived from Microsoft BASIC, it is possible to output screen-editor control codes in PRINT statements. Thus a common technique used to create dynamically-generated BASIC lines is to PRINT the generated line followed by control codes to return to the start of the line and then ...


18

The Sinclair systems were tokenised directly at the keyboard, so there was almost no lexical analysis. Keys were inputs to a state machine that implemented the BASIC language structure in a ROM table. The first keystroke would have a label on it -- maybe the P key was also labelled Print, G was Goto, and the L key was Let. After that was hit, the state ...


17

You need to use OpenMSX, and get the system ROMs for the machine in question. Then run OpenMSX, set the machine to the FS-A1WSX. There's a little menu button at the top left of the OpenMSX window. In there, set your tape to the WAV file. Then: 10 M$ = "E4E8O3G16G32R32G2G4R4O4C8D8E8F8G2G8F8E8F4E8D8E4D8C4" 20 PLAY M$+M$ The listing above is the content of ...


16

The disk handling routine at 15619 will look ahead in the currently-executing BASIC line to see what command needs to be performed. As Ross Ridge observes, it evidently doesn't modify the BASIC interpreter's internal state when doing this, and so when the RANDOMIZE USR 15619 call returns, the interpreter will continue at the next statement. If the REM wasn't ...


16

Most implementations of BASIC for 8-bit home computers were interpreters, and in that sense they're similar to the standard versions of Python. You could typically expect simple programs to run 100 times slower in BASIC than in assembly of ordinary quality. However, it would normally take much less time to write that program in BASIC than in assembly. For ...


16

Here is the listing for Motie, followed immediately by Rescue. The full list of archived issues of People's Computer Co. (PCC) is here.


16

Most early 8-bit personal computer Basic interpreters were tokenized recursive descent interpreters. Tokenized to reduce the size of the program text, as well as speed up the interpreter by not have to parse text at runtime, and runtime recursive descent, trading off stack space usage versus having to build a parse tree in memory beforehand. Very few (if ...


15

GW-BASIC allowed you to load in arbitrary code using CHAIN MERGE, where you could take an ASCII-coded (non-binary) BASIC program or snippet and transfer control to a specific line number. As no renumbering occurred, you could overwrite or remove sections of your code prior to the chaining. This program snippet works in this PC-BASIC emulator: 10 PRINT "...


15

were these interpreters implemented as tree-walker interpreters (simply traversing the parse tree) or bytecode interpreters? I have been looking at various BASICs for the last while. The answer is "all of the above". Pure interpreters - Tiny BASIC TinyBASIC parsed the line to the extent of converting the line number to an 8-bit value to see if the line ...


14

I think the earliest BASIC dialects on micros to use these constructs for strings were North Star BASIC and Apple Integer BASIC in 1977, both presumably influenced by HP BASIC. The Apple lineage isn’t surprising since Steve Wozniak worked at HP. The origin of this approach to substring addressing could be FORTRAN, which uses a syntax of the form A(I:L).


14

BBC BASIC didn't use the PEEK or POKE keywords, but had the ? operator and statement which had the same effect. So the statement ?128 = 0 is equivalent to POKE 128, 0, and the expression ?128 is equivalent to PEEK 128. However, it also had ! and $ which did 32-bit and string peeks and pokes and e.g. $128 = "HELLO" would write the ASCII bytes of "HELLO" into ...


13

Using this expression A-INT(A/B)*B


12

On the original Dartmouth Time-Sharing BASIC (circa 1964), the maximum line number was 99999. Dartmouth Time-Sharing ran on a hybrid Datanet-30 / GE 235 system. The Datanet-30 could communicate with up to 128 terminals at once, and handled the I/O. The GE 235 was better at computation and was responsible for executing the BASIC programs. 99999+1 was the ...


12

The TRS-80 series is Z80 based, and Z80 uses, like all 8080 offspring (*1,3) a separate address space for I/O. It allows easy decoding for I/O. Thus memory address 0000h is different from I/O address 00h. On logical (program) level, access to either address space is selected by the instructions used. Memory instructions always access memory address space ...


11

INPUT LINE a$ See the ZX Spectrum Basic manual. Note that plain INPUT a$ will accept quite arbitrary string expressions, e.g. entering "a"+"b" is the same as entering "ab", and you can even use other (defined) string variables. The quotes are thus nothing more than a part of the string expression.


10

M-BASIC-80 knows the modifier "A" for the SAVE command - So, you should be able to create a readable ASCII file directly on the Kaypro computer by doing LOAD "MYPROG.BAS" LIST SAVE "MYPROG.TXT",A If you don't want to mess with old disks on a modern computer (I recommend you don't even start to look into this), your best bet would be to set up a serial RS-...


10

MOD is an operator, not a function. Try ? 10 mod 9 and see yourself.


10

Probably the most modern BASIC available for the 6502 - though it requires a 65C02 - is Acorn's BBC BASIC IV as released for the BBC Master. It can be ported to other 65C02-based hardware by implementing a few of the MOS API entry points it relies on, and dummying out the rest; several people have done so for home-built SBCs. The standard version occupies ...


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