BASIC extensions ROM

want to request software or documentation that you can't find online? post in here!
Post Reply
User avatar
leenew
Posts: 3863
Joined: Wed Jul 04, 2012 3:27 pm
Location: Doncaster, Yorkshire
Contact:

BASIC extensions ROM

Post by leenew » Mon May 13, 2019 11:07 pm

Has anyone seen this before?
https://rover.ebay.com/rover/0/0/0?mpre ... 3725413345

It went for a pretty penny so I guess it is rare?

Lee.

User avatar
Pernod
Posts: 1507
Joined: Fri Jun 08, 2012 10:01 pm
Location: Croydon, UK
Contact:

Re: BASIC extensions ROM

Post by Pernod » Mon May 13, 2019 11:12 pm

Readily available from http://bbc.nvg.org/rom/Various/lang/BAS ... ns-1.2.rom

Probably quite rare to find original and a worthwhile find for a Micro Power collector.
Last edited by Pernod on Tue May 14, 2019 12:59 am, edited 1 time in total.
- Nigel

BBC Model B: ATPL Sidewise, Acorn Speech, 2xWatford Floppy Drives, AMX Mouse, Viglen case, BeebZIF, etc.

User avatar
Elminster
Posts: 3282
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

Re: BASIC extensions ROM

Post by Elminster » Tue May 14, 2019 8:21 am

I have the box and the manual. But not the original ROM.

Edit: Uploaded scanned manual here viewtopic.php?f=55&t=13283&hilit=extension#p174343
Edit2: Paid £6.22 for it in 2017, the same but was missing the original ROM.
Last edited by Elminster on Tue May 14, 2019 8:26 am, edited 4 times in total.

User avatar
leenew
Posts: 3863
Joined: Wed Jul 04, 2012 3:27 pm
Location: Doncaster, Yorkshire
Contact:

Re: BASIC extensions ROM

Post by leenew » Tue May 14, 2019 9:17 am

Thanks guys :D

Lee.

User avatar
lurkio
Posts: 2031
Joined: Tue Apr 09, 2013 11:30 pm
Location: Doomawangara
Contact:

Re: BASIC extensions ROM

Post by lurkio » Wed May 15, 2019 12:50 am

Never used any of the various BASIC extension ROMs before, so I thought I'd give this Micro Power one a spin. I must say it looks odd at first to see a BBC BASIC program with strange new keywords like FIF and ELSEIF (which isn't the same as other languages' elseifs!), but they do solve the nested-IFs problem, as seen in the following program:

Code: Select all

REM This program doesn't do what you might expect: it prints "A>2" even though A is 1.
10 A=1
20 IF A>1 IF A=2 PRINT "A=2" ELSE PRINT "A>2"

This program behaves better:

Code: Select all

REM This program prints nothing when A is 1 because the FIFs nest intuitively: 
10 A=1
20 FIF A>1 FIF A=2 PRINT"A=2":ELSEIF PRINT "A>2":ENDIF:ENDIF

Run both programs in JSBeeb:

Neat. I'll have to play with the Micro Power BASIC Extensions ROM some more.

Btw, here are the photos of the box and its contents, for the archive:

s-l1600.jpg
s-l1600-2.jpg
s-l1600-3.jpg
s-l1600-4.jpg

:idea:
Last edited by lurkio on Wed May 15, 2019 7:39 pm, edited 1 time in total.

User avatar
lurkio
Posts: 2031
Joined: Tue Apr 09, 2013 11:30 pm
Location: Doomawangara
Contact:

Re: BASIC extensions ROM

Post by lurkio » Wed May 15, 2019 7:44 pm

Got the Micro Power BASIC Extensions ROM working in JSBeeb.

See link in previous post, above.

:idea:

User avatar
Elminster
Posts: 3282
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

Re: BASIC extensions ROM

Post by Elminster » Wed May 15, 2019 9:32 pm

There were various theads about this, some started by me, and I dare say you contributed to some, but I think in the end I just used Basic V on the Beeb rather than the various BASIC extensions.

User avatar
lurkio
Posts: 2031
Joined: Tue Apr 09, 2013 11:30 pm
Location: Doomawangara
Contact:

Re: BASIC extensions ROM

Post by lurkio » Thu May 16, 2019 8:52 am

Elminster wrote:
Wed May 15, 2019 9:32 pm
... in the end I just used Basic V on the Beeb rather than the various BASIC extensions.
Remind me which model of Beeb and/or which copro you need in order to run BASIC V..?

:?:

User avatar
Elminster
Posts: 3282
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

Re: BASIC extensions ROM

Post by Elminster » Thu May 16, 2019 9:03 am

Called Advanced Basic on Beeb, takes up 2 ROMs from memory (instead of 1, but then so does normal basic + rom basic extension). And yes need some sort of 6502 co pro.

Edit: Here is one where I was talking to myself :) viewtopic.php?f=55&t=13151&hilit=advanced+basic

Edit2: This is a link where I linked to all the links viewtopic.php?f=2&t=15298&hilit=advanced+basic#p207046
Last edited by Elminster on Thu May 16, 2019 9:06 am, edited 2 times in total.

Coeus
Posts: 1208
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: BASIC extensions ROM

Post by Coeus » Sat May 18, 2019 11:56 pm

lurkio wrote:
Wed May 15, 2019 12:50 am

Code: Select all

REM This program doesn't do what you might expect: it prints "A>2" even though A is 1.
10 A=1
20 IF A>1 IF A=2 PRINT "A=2" ELSE PRINT "A>2"
Was ELSE in MS BASIC at the time, on the assumption that is the closest thing there was to a standard. It does seem that the ELSE clause was a bit of an afterthought and I am pretty sure I remember reading in one of the BASIC ROM disassemblies that when the condition of an IF is tested and found to be false the interpreter simply searches forward for an ELSE and if it finds one, continues execution from there so when the A>1 evaluates to false it finds the ELSE PRINT "A>2" and executes that.

Once you know that is the behaviour, though, can't you re-work it as:

Code: Select all

IF A>2 PRINT "A>2" ELSE IF A=2 PRINT "A=2"
The only time you would not be able to re-arrange the tests in that way is if you wanted an outer IF with an ELSE and each part of that had another IF nested within it.
Last edited by Coeus on Sat May 18, 2019 11:56 pm, edited 1 time in total.

User avatar
Richard Russell
Posts: 720
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: BASIC extensions ROM

Post by Richard Russell » Sun May 19, 2019 7:20 am

Coeus wrote:
Sat May 18, 2019 11:56 pm
It does seem that the ELSE clause was a bit of an afterthought and I am pretty sure I remember reading in one of the BASIC ROM disassemblies that when the condition of an IF is tested and found to be false the interpreter simply searches forward for an ELSE and if it finds one, continues execution from there
I have no recollection of ELSE being an "afterthought" and once you know how it works it seems entirely consistent to me. I'm not even sure it could work a different way without sacrificing the use of IF for short-circuit evaluation, in other words using IF instead of AND:

Code: Select all

IF condition1 AND condition2 AND condition3 THEN ..... ELSE ....
IF condition1 IF condition2 IF condition3 THEN .... ELSE ....
This is a phenomenally useful technique, both for boosting speed (no need to evaluate the subsequent conditional expressions if the first is FALSE) and to prevent side-effects if one of the later expressions includes an FN. I wouldn't want to sacrifice it on the altar of more 'intuitive' behaviour. Possibly one could have the best of both worlds by making THEN compulsory rather than (usually) optional but that would be a major change to the language.

mr-macrisc
Posts: 256
Joined: Wed Feb 07, 2018 3:35 pm
Contact:

Re: BASIC extensions ROM

Post by mr-macrisc » Sun May 19, 2019 11:22 am

If ya ever write macros in spreadsheets IF ELSE THEN are hugely useful.

Coeus
Posts: 1208
Joined: Mon Jul 25, 2016 11:05 am
Contact:

Re: BASIC extensions ROM

Post by Coeus » Sun May 19, 2019 12:03 pm

Richard Russell wrote:
Sun May 19, 2019 7:20 am
I have no recollection of ELSE being an "afterthought" and once you know how it works it seems entirely consistent to me.
When I say afterthought, I don't mean that BBC BASIC was ever proposed without it but that I wonder if in the history of BASIC as a language it was not originally present and was added later by the writers of a particular interpreter who did what was easiest and that became a defacto standard that everyone else copied.

I'll admit, though, that I am looking back from the perspective of block structured programming languages where the norm is to consider the else to go with the immediately preceding if unless block markers ({} or begin end) dictate otherwise.
Richard Russell wrote:
Sun May 19, 2019 7:20 am
I'm not even sure it could work a different way without sacrificing the use of IF for short-circuit evaluation, in other words using IF instead of AND:

Code: Select all

IF condition1 AND condition2 AND condition3 THEN ..... ELSE ....
IF condition1 IF condition2 IF condition3 THEN .... ELSE ....
I remember thinking at the time that not doing short circuit evaluation in the more standard form of the IF statement was sub-optimal but maybe the fault is in material written to help people learn BASIC which did not introduce the multiple IF technique. Perhaps the writers came from other languages.

User avatar
Richard Russell
Posts: 720
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: BASIC extensions ROM

Post by Richard Russell » Sun May 19, 2019 4:08 pm

Coeus wrote:
Sun May 19, 2019 12:03 pm
I remember thinking at the time that not doing short circuit evaluation in the more standard form of the IF statement was sub-optimal
OR and AND (along with EOR) are crucially bitwise operators, in addition to their use in conditional expressions, so short-circuit evaluation could never have been the default behaviour. A (very) few BASICs support it as an option using different keywords (e.g. ANDALSO, ORELSE).

User avatar
lurkio
Posts: 2031
Joined: Tue Apr 09, 2013 11:30 pm
Location: Doomawangara
Contact:

Re: BASIC extensions ROM

Post by lurkio » Sun May 19, 2019 7:01 pm

Although my first real exposure to any programming language was to BBC BASIC in the 80s, I didn't become aware of the peculiarities of its IF..THEN..ELSE construction till recently, by which time I'd come across "fully nested" IFs in other languages, most of which looked something like this:

Code: Select all

if condition1 then 
{
  statement 1
  statement 2
  ...
  if condition 2 then 
  {
    statement 3
    ...
  }
  else 
  {
    statement 4
    ...
  }
}
else 
{
  statement 5
  ...
}
Going back to BBC BASIC's non-nesting IFs was therefore a bit of a surprise, as for example when I tried to convert a listing to BBC BASIC from Tandy/TRS-80 BASIC (which does seem to nest its IFs):

Btw, BBC BASIC's "empty THEN" construction was another thing I discovered recently and found somewhat surprising, but also useful:

Code: Select all

10 A=1
20 IF A<=1 THEN ELSE IF A=2 THEN PRINT "A=2" ELSE PRINT "A is greater than 2"
:idea:

User avatar
Richard Russell
Posts: 720
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: BASIC extensions ROM

Post by Richard Russell » Mon May 20, 2019 4:22 pm

lurkio wrote:
Sun May 19, 2019 7:01 pm
I didn't become aware of the peculiarities of its IF..THEN..ELSE construction till recently, by which time I'd come across "fully nested" IFs in other languages, most of which looked something like this:
The BBC BASIC equivalent is the multi-line IF ... ENDIF clause (available from ARM BASIC V onwards) which works substantially the same as every other BASIC as far as I'm aware. Certainly you can nest IF clauses to any depth in the way you showed, and each ENDIF pairs with the matching IF in the expected way:

Code: Select all

    IF condition1 THEN
      IF condition2 THEN
        IF condition3 THEN
          ...
        ENDIF
        ...
      ENDIF
      ...
    ENDIF
The only 'oddity' is that in BBC BASIC you are not allowed to have anything at all after the THEN (not even a REMark): it must be the very last thing on the line.

The previous discussion in this thread was about the single-line IF statement, not the multi-line IF ... ENDIF clause. ENDIF is not used in single-line IFs so since there is nothing which explicitly identifies the end of an IF clause (and because BASIC doesn't delimit blocks with { ... } like C does for example) I would not necessarily expect any particular behaviour if there is more than one IF on the line. The way BBC BASIC works seems as sensible as any other in that respect.

User avatar
jgharston
Posts: 3497
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: BASIC extensions ROM

Post by jgharston » Tue May 21, 2019 8:51 am

The functioning of a single-line IF, of *any* single-line IF is always:
if clause is non-zero, continue executing from that point onwards
if clause if zero, scan the line forwards to an ELSE or end-of-line, and continue executing from that point onwards
THEN is executed as a null statement
ELSE is executed as: scan to the end of the line and continue executing from that point onwards.*

It's only when you start inserting exceptions into your thinking that you will confuse yourself.

*ELSE is essentially a tokensied REM. Try (on a non-32bit-equivalent BASIC):
10ELSE P."Hello"

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

User avatar
Richard Russell
Posts: 720
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: BASIC extensions ROM

Post by Richard Russell » Tue May 21, 2019 4:08 pm

jgharston wrote:
Tue May 21, 2019 8:51 am
ELSE is essentially a tokensied REM.
In the C source code for BBC BASIC for SDL 2.0 you can see that the interpreter treats DATA, DEF, ELSE and REM identically when encountered during normal execution:

Code: Select all

/************************************* REM *************************************/

			case TREM:
			case TDEF:
			case TDATA:
			case TELSE:
				esi = (signed char*) memchr ((char *) esi, 0x0D, 255) ;
				break ;

(this is from bbexec.c at GitHub).

User avatar
jgharston
Posts: 3497
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: BASIC extensions ROM

Post by jgharston » Tue May 21, 2019 7:40 pm

Ditto PDP11 BASIC:

Code: Select all

; Skip past a line, *command, REM, etc
; ------------------------------------
.cmdELSE
.cmdREM
.cmdDEF
.cmdDATA
.SkipLine
cmpb (r5)+,#13		; Get character
bne  SkipLine		; Loop until <cr>
.SkipLineDone
dec  r5			; Point to <cr>
rts  pc
and 6502 BASIC:

Code: Select all

\ DATA, DEF, REM, ELSE
\ ====================
\ Skip to end of line
\ -------------------
.L8B7D
LDA #&0D:LDY &0A:DEY      :\ Get program pointer
.L8B82
INY:CMP (&0B),Y:BNE L8B82 :\ Loop until <cr> found
.L8B87
CMP #tknELSE:BEQ L8B7D    :\ If 'ELSE', jump to skip to end of line
LDA &0C:CMP #(ws+&0700)DIV256:BEQ L8B41:\ Program in command buffer, jump back to immediate loop
JSR L9890:BNE L8BA3       :\ Check for end of program, step past <cr>

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

Post Reply