Hot answers tagged

57

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 ...


40

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 ...


36

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. ...


24

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 ...


22

Well, it's a 'trick' to simplify the editor as well as the BASIC editor. After Reset (or NEW) three bytes of Zero are placed at the beginning of the basic RAM. They make it look to the basic interpreter as this looks like the tokenisation of a single, empty BASIC line. Consisting of One byte 00 as line end marker and Two bytes 00 as pointer to the next ...


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 ...


18

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 ...


15

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 ...


14

This example reveals a rounding error under Commodore BASIC V2.0: A=0.3:B=0.6:IF A+B<>0.9 THEN PRINT A+B-0.9 Running this on a C64 yields a difference of 2.32830644e-10. Other pairs that fail are 0.4+0.5, 0.6+0.1 and 0.8+0.1. Please note that also the order in which the numbers are summed up affects the result. 0.6+0.1-0.7 yields a difference, ...


14

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 "...


13

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


13

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).


12

SYS is the BASIC instruction to execute a routine written in machine code. There is no more BASIC code to view, the entire game is implemented as a machine code program, and the BASIC only exists as a stub to make it easier to load and run. The best approach to viewing what the code actually does and potentially being able to restore your table (if it is ...


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-...


9

Here is my favourite example for this problem. I often use it to show Excel's mathematical shortcomings, but not surprisingly it works the same in the C64: 10 A = 0.1 20 B = 0.1 30 FOR I = 1 TO 10 40 D = B 50 B = 20 * A - 19 * B 60 PRINT B 70 A = D 80 NEXT I In every iteration, the algorithm should be doing 20 * 0.1 - 19 * 0.1 = 0.1, but the output on this ...


9

The ZX Spectrum has VAL function, which is able to evaluate a string as a numeric expression. Such string can contain any valid BASIC expression. VAL$ does the same but with string expressions. On the other hand, the SAM Coupé BASIC (influenced by the Sinclair BASIC to some extent) has KEYIN, which allows a BASIC program to interpret a string as a BASIC ...


7

Some old Operating Systems I hear have only BASIC Programming Language It was more the case that BASIC was the operating system. Various commands for working with devices like floppy disks and printers were added to the dialect of BASIC running on that machine. Turning it on would result in the BASIC READY prompt where you could type in a program, or begin ...


7

Atari BASIC included the "ENTER" keyword, which was the "opposite of" LIST. Whereas LIST wrote a program to text, ENTER read a program from text. One could use ENTER to read libraries by adding those lines to an existing program. In contrast to most BASICs, Atari BASIC did not have any limitations between which keywords would operate in interactive mode vs. ...


6

RISC OS Pico on the Raspberry Pi boots to BASIC. See https://www.riscosopen.org/content/downloads/raspberry-pi The "full fat" RISC OS could also be made to boot to BASIC using *CONFIGURE commands like you can with the Archimedes and RISC PC. Note that riscosopen.org do not list the RasPi4 as being compatible (and RISC OS Pico has a smaller compatibility ...


6

[...] Commodore 64 did indeed provide 64K of RAM [...] only 38K was usable from BASIC; [...] bank switching was needed to get at the rest, And that's exactly the way the TED computers did use. but if a BASIC program switched out the [...] ROM, [...] it would of course promptly crash. Well, BASIC 3.5 was aware of that and did provide functions for ...


6

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


6

It wouldn't happen to be the one that the listing starts/ends like this, would it? 10 'EXPANDED APRIL 1977 BY W.A. BURTON 20 'PIRATED JAN. 1978 BY ZOSO 30 DIM G(8,8),S(8,8),K(3,3) 40 PRINTCHR$(26) 50 GOSUB 5460 … 6350 IF Q8<0 OR Q8>S THEN GOTO 6340 6360 S=S-Q8:E=E+Q8:PRINT 6370 PRINT E;" UNITS OF ENERGY NOW - TRY AGAIN." 6380 RETURN 6390 RESET If ...


6

Applesoft BASIC, as I recall, treated ASCII character 4 (control-D) as an escape code to DOS or ProDOS. You could therefore give the interpreter commands such as PRINT CHR$(4)"WRITE filename", and to run a different program.


6

Complete reedit due to new information and 30K limit Ok I tried your new files. the files without extensions should have *.HPI extensions (HP Image) and should be decoded to files first. They have HFSLIF signature at start. To decode them the easiest is to use emulator. However to do this on your own we need either decoding table + fileformat description ...


5

Might I suggest you try 0.11+0.12? I believe IEEE754 will in fact give the right answer on 0.1+0.2=0.3, using standard single precision. It is, however, not difficult to provoke IEEE754 failures, for instance on 0.11+0.12. The C program below show the raw bin32 representations of the relevant IEEE754 numbers, the program output is: a :3dcccccd b :...


5

A lot of Commodore 8-bit computer games used a disk that had random-access files on them. This means they were written directly to disk blocks, not via a program, sequential or relative file, which are the three ways Commodore DOS officially supports files. Random files are protected by having the programmer manually mark the blocks as being used. This ...


5

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 ...


5

Well this certainly isn't exhaustive, but from what I can see the answer is no. I still find it fascinating that the Soviet basic school computer was a PDP-11 in a micro format. It makes me wonder what our systems of the era would have been like given a similar CPU. In any event, this is also a rather limiting factor. Porting MS BASIC from one 8-bit ...


5

First, we must ask "what is self-modifying code?" This can mean a few things. One type is code which modifies the on-disk (or on-tape) version of the code, then re-loads and re-executes it. I don't think this is what the question is asking about. I think it wants code that modifies itself in memory, while it is running, without having to reload. Another is ...


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