Abasic2/3 and SBasic2/3

discussion of games, software, hardware & emulators relating to the Acorn Atom
Post Reply
Prime
Posts: 2554
Joined: Sun May 31, 2009 11:52 pm
Contact:

Abasic2/3 and SBasic2/3

Post by Prime » Wed Jan 24, 2018 9:41 am

Hi all,

I've been playing with abasic2/abasic3 (and sbasic2 /3 on my system clone). And have noticed the following problem.

If you try to save a program with save "filename", a file is created but the basic code is not saved into it.

Doing a *info on the saved file :

*INFO TEST
TEST 2800 401C 0FFF4 002

Which doesn't look correct. Looking at the disk in a hex editor shows that no actual file data is written to the disk, hardly supprising since the length is -ve :(

This also seems to affect the System port, which is where I first discovered it, but wanted to check the Atom port too...

I did check the original SBASIC which is supplied on one of the system floppies, and that does save and load correctly, also SBASIC2 / SBASIC3, can load files saved by it without problems.

Cheers.

Phill.

Prime
Posts: 2554
Joined: Sun May 31, 2009 11:52 pm
Contact:

Re: Abasic2/3 and SBasic2/3

Post by Prime » Wed Jan 24, 2018 10:27 am

A little bit more digging in Atomulator......

I trapped at OSSAVE : $FFDD :

Code: Select all

FFDD : JMP (020E)    >r
    6502 registers :
    A=28 X=37 Y=28 S=01FD PC=FFDD
    Status :      C
FFDD : JMP (020E)    >m 37
    0037 : 00 9E 00 28 1C 40 28 28 1D 28 00 00 00 00 00 00   .×.(.@((.(......
So this looks like :
filename at $009E,
load address at $2800,
Exec at $401C,
start of data $2828
end of data $281D

That certainly explains why it's getting a -ve file length as end address is before start :( But also there is no data at $2828, the tokenized basic program is at $2800

Code: Select all

FFDD : JMP (020E)    >m 2800
    2800 : 0D 00 0A 10 20 F1 20 22 54 45 53 54 21 20 22 3B   .... ± "TEST! ";
    2810 : 0D 00 14 0B 20 E5 20 8D 54 4A 40 0D FF 00 00 00   .... Õ ìTJ@. ...
It does appear to end at $281D tho, so I suspect that something is corrupting the start address....

I tried patching the start address to $2800 and the save completed correctly and I was able to load it back in again.

Cheers.

Phill.

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

Re: Abasic2/3 and SBasic2/3

Post by jgharston » Wed Jan 24, 2018 5:11 pm

I was sure it worked when I created them some years ago. I'll boot up the A5000 and re-check the code.

Code: Select all

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

Prime
Posts: 2554
Joined: Sun May 31, 2009 11:52 pm
Contact:

Re: Abasic2/3 and SBasic2/3

Post by Prime » Wed Jan 24, 2018 6:58 pm

jgharston wrote:I was sure it worked when I created them some years ago. I'll boot up the A5000 and re-check the code.
Cheers :)

Looking at the code I wonder if the problem is in the .LBEDD routine :

Code: Select all

\ Set FILE.LOAD to MEMHI.PAGE
\ ---------------------------
.LBEDD
JSR LBED2:DEY:STY F_LOAD+0
LDA &18:STA F_LOAD+1        :\ LOAD=PAGE
.LBEE7
OPT FNif(target$<>"atom")
 LDA #&82:JSR OSBYTE        :\ Get memory base high word
 STX F_LOAD+2:STY F_LOAD+3  :\ Set LOAD high word
 LDA #&00
OPT FNendif
RTS
Specifically that the LDA #0 is missed if the target is atom, as on return the value of A is saved in F_START+0 which seems to be causing the problem.

I would have tried re-assembling myself, but don't have the correct version of BBC basic.....wonder if it would run on an archemedes emulator :)

Cheers.

Phill.

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

Re: Abasic2/3 and SBasic2/3

Post by jgharston » Wed Jan 24, 2018 10:15 pm

I had a look at the code on my slo-mo A4000 (my A5000 has acid indigestion). All three versions of the Atom and System BBC BASIC save ok here (using a custom Client for 65Tube that provides the System/Atom API), and I'm sure saving worked when I demo'd it at a Bolton ABUG a couple of years ago, as I'm sure I tweeked the Tiny65 disassembler there.

I last looked at the code some years ago. An oddity is the zipped source is stamped Oct-2013, the last comment in the source is Jan-2014 adding the test for Escape on the Atom, and the source file's date-stamp is Jan-2015, and the disk image is stamped Jul-2015. Really wierdly, index/htm is typed BASIC instead of HTML!

With the disk image being dated Jul-2015 it should have the code from the Jan-2014 source regardless of the uploaded source code. It could be you've got a version that was built from a translation to BeebAsm that was based on that Oct-2013 zipped source. The Oct-2013 source started up saying "BBC BASIC", the Jan-2014 code squeezed enough space to start up saying "BBC BASIC II" or "BBC BASIC III".

I've rebuilt everything and re-uploaded everything to ensure everything is fresh.
http://mdfs.net/Software/BBCBasic/System/ and
http://mdfs.net/Software/BBCBasic/Atom/

I've also sanity-checked the disassembly SAVE code, it it looks ok to me (checking the source can be a bit fiddly with all the IF/ELSE/ENDIF blocks):

Code: Select all

DF00 20 F5 DE     u^  JSR &DEF5  :\ Set F_NAME=>filename
DF03 88          .    DEY        :\ Y=&00
DF04 84 39       .9   STY &39    :\ Set F_LOAD.lo=&00
DF06 A5 18       %.   LDA &18
DF08 85 3A       .:   STA &3A    :\ Set F_LOAD.hi=PAGEhi
DF0A 60          `    RTS

\ SAVE string$
DF0B 20 79 DE     y^  JSR &DE79  :\ Check program, set TOP
DF0E A5 12       %.   LDA &12    :\ Set F_END=TOP
DF10 85 3F       .?   STA &3F
DF12 A5 13       %.   LDA &13
DF14 85 40       .@   STA &40
DF16 A9 1E       ).   LDA #&1E   :\ Set E_EXEC=STARTUP
DF18 85 3B       .;   STA &3B
DF1A A9 A0       )    LDA #&A0
DF1C 85 3C       .<   STA &3C
DF1E A5 18       %.   LDA &18    :\ Set F_START.hi=PAGEhi
DF20 85 3E       .>   STA &3E
DF22 20 00 DF     ._  JSR &DF00  :\ Set F_LOAD=PAGE, F_NAME=>filename
DF25 84 3D       .=   STY &3D    :\ Set F_START.lo=&00
DF27 A8          (    TAY        :\ Y=&??, System/Atom ignores Y
DF28 A2 37       "7   LDX #&37   :\ X=&37 => control block
DF2A 38          8    SEC
DF2B 20 DD FF     ].  JSR &FFDD  :\ Call OSSAVE
DF2E 4C 93 AB    L.+  JMP &AB93
Specifically that the LDA #0 is missed if the target is atom, as on return the value of A is saved in F_START+0 which seems to be causing the problem.
Yes, for the System/Atom it should be using Y, as A has been trashed by setting F_LOAD. A bell rings faintly that BASIC IV optimised this to removed the extra LDA#0 needed. It looks like the uploaded Basic2.zip didn't get refreshed to match the working code.

Code: Select all

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

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

Re: Abasic2/3 and SBasic2/3

Post by jgharston » Wed Jan 24, 2018 10:24 pm

The Tube Client that I use to get a System/Atom API on a 6502 CoPro is at:
http://mdfs.net/Software/Tube/6502/Atom/

With that you can do *Atom65 or *AtomTube and to programs running on the CoPro it looks like it's running on an Atom or System, without any of the Atom/System hardware.

Edit: hold on, that's not right. On the system here it's Software/Tube/Atom not Software/Tube/6502/Atom

Code: Select all

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

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

Re: Abasic2/3 and SBasic2/3

Post by jgharston » Wed Jan 24, 2018 10:57 pm

jgharston wrote:http://mdfs.net/Software/Tube/6502/Atom/
Edit: hold on, that's not right. On the system here it's Software/Tube/Atom not Software/Tube/6502/Atom
Well, that's a bit of a mess. What I must have done is create a directory for "Tube/6502 client code/for Atom", then when writing an Atom Tube host renamed it as "Tube/Atom code" but still with "Tube/6502 client code/for Atom" in it. Or possibly the other way around. Or something. Anyway, that means that my website updater program won't have uploaded updated files to the correct directories on mdfs.net.

Code: Select all

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

Prime
Posts: 2554
Joined: Sun May 31, 2009 11:52 pm
Contact:

Re: Abasic2/3 and SBasic2/3

Post by Prime » Thu Jan 25, 2018 10:34 am

I've downloaded and checked the Atom versions in Atomulator and they now appear to be saving correctly thanks. This was once I figured out that Firefox was still giving me a cached copy from yesterday, and downloaded a new one with chrome!

I'll check the system versions when I'm at home this evening.......update all working now.

Cheers.

Phill.
Last edited by Prime on Thu Jan 25, 2018 7:01 pm, edited 1 time in total.

User avatar
jbnbeeb
Posts: 424
Joined: Sat Apr 03, 2010 8:16 pm
Contact:

Re: Abasic2/3 and SBasic2/3

Post by jbnbeeb » Thu Jan 25, 2018 10:51 am

I'm curious to find out how closely these versions of Acorn BASIC resemble BBC BASIC. I'm sure I've read recently (on *.) that BBC BASIC was likely developed on a System - which makes sense.

Is SBASIC aka "Super BASIC" and does it have some BBC BASIC key words like PROC? Or is it closer in lineage to Atom BASIC?
I'm going to ..
ABUG Cambridge Sept 7th-9th Sept 2018
Image

Prime
Posts: 2554
Joined: Sun May 31, 2009 11:52 pm
Contact:

Re: Abasic2/3 and SBasic2/3

Post by Prime » Thu Jan 25, 2018 7:06 pm

jbnbeeb wrote:I'm curious to find out how closely these versions of Acorn BASIC resemble BBC BASIC. I'm sure I've read recently (on *.) that BBC BASIC was likely developed on a System - which makes sense.

Is SBASIC aka "Super BASIC" and does it have some BBC BASIC key words like PROC? Or is it closer in lineage to Atom BASIC?
They are both BBC basic 2/3 assembled to run on the native environments of the System (sbaisc) and Atom (abasic), obviously they won't be able to access the graphic modes / sound etc that the beeb has but for anything that the hardware can support it should run. The real difference between them is that the Atom variant is loaded at $4000 and the system variant is loaded at $A000, but that's just down to where the RAM is in the memory maps of the twom machines.

Cheers.

Phill.

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

Re: Abasic2/3 and SBasic2/3

Post by jgharston » Sat Jan 27, 2018 12:08 am

jbnbeeb wrote:I'm curious to find out how closely these versions of Acorn BASIC resemble BBC BASIC. I'm sure I've read recently (on *.) that BBC BASIC was likely developed on a System - which makes sense.
Is SBASIC aka "Super BASIC" and does it have some BBC BASIC key words like PROC? Or is it closer in lineage to Atom BASIC?
SBASIC is BBC BASIC for the System - SystemBASIC. It isn't similar to BBC BASIC or have some of BBC BASIC's keywords, it *IS* BBC BASIC.

From examining the code it looks very much like BBC BASIC was developed on a System, with build flags to not include BBC-specific calls (eg to OSWORD) and to include code to implement core features that the System lacked (eg READLINE, TAB(x,y)). The code is about 98% identical to BBC BASIC 1 - see the source here. In fact, in a couple of places it looks like the code I got hold of has a couple of the bugsfixes that went into BASIC II: EVAL() sets the tokeniser to "functions" instead of "commands" so eg EVAL("TIME") works, and the ON x GOSUB ELSE bug appears to be fixed.

I took the re-created source and added similar build flags to target the Atom (checking Escape is different), and also carried the Atom and System code into the BASIC II/III source to build BASIC II and III to target the Atom and System.

Prompted by the other thread, yesterday I found a few bytes to squeeze to tweek the Atom code to force all system messages into upper case. There's a BeebAsm version of the code on GitHub which splits the code into 4K+12K so it can be ROM'd on the Atom, I've made a note to do that as well.

According to the comments in the source, I last looked at it four years ago!!!

Code: Select all

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

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

Re: Abasic2/3 and SBasic2/3

Post by jgharston » Fri Feb 02, 2018 1:58 am

Just a bit of fun, but I was looking at the 40-column (teletext) System Kernel code and was able to tweek it to do teletext character conversion so ASC"#", ASC"_", ASC"£" are displayed as # _ £ as on the Beeb: SYS5-40.zip

8271 disk controllers are like gold-plated hens' teeth nowadays, so I'm tempted to rewrite the DOS to use a 1770. Unfortunately, I don't have anything to test it on. ;)

Code: Select all

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

Prime
Posts: 2554
Joined: Sun May 31, 2009 11:52 pm
Contact:

Re: Abasic2/3 and SBasic2/3

Post by Prime » Fri Feb 02, 2018 9:25 am

jgharston wrote:Just a bit of fun, but I was looking at the 40-column (teletext) System Kernel code and was able to tweek it to do teletext character conversion so ASC"#", ASC"_", ASC"£" are displayed as # _ £ as on the Beeb: SYS5-40.zip
Right I'll have a go at merging that into my source, do you have the source bits you changed or did you just do a binary patch?
8271 disk controllers are like gold-plated hens' teeth nowadays, so I'm tempted to rewrite the DOS to use a 1770. Unfortunately, I don't have anything to test it on. ;)
It shouldn't be too dificult, that's effectively what I did when I ported Acorn's Atom DOS to use the 1770 when I producecd the run of Atom 1770 based floppy controllers. So a lot of the routines could probably be transplanted as is, as Atom dos, is effectively a re-targeted system dos.

Though for people with a genuine Acorn system machine I guess they are going to have the 8271 floppy controller if they have disks. Even my clone has an 8271, though it is out of a beeb I upgraded to a 1770 DFS :)

Though it should also be possible to plug a 1770 DFS module into the 8271 socket on a System / Atom card and re-write the dos to use them (as was done on 1770 DFS on the beeb), plus it has the advantage of not needing the ready-faker circuit which is something I'm having problems with on my clone interface at the mo.

Cheers.

Phill.

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

Re: Abasic2/3 and SBasic2/3

Post by jgharston » Fri Feb 02, 2018 7:07 pm

Prime wrote:Right I'll have a go at merging that into my source, do you have the source bits you changed or did you just do a binary patch?
http://mdfs.net/System/ROMs/AcornMOS/Sy ... YS5-1F.zip

It's a bit untidy as I was thinking about something else while I was working on it.

if VDU%=40 and chrtx% is TRUE, it does the character translation. At the moment it frees a bit of room by removing the printer driver.

Code: Select all

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

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

Re: Abasic2/3 and SBasic2/3

Post by jgharston » Sat Feb 03, 2018 3:20 am

Here we are, a bit of tidying and I've put the printer code back in again:
SYS5-40.zip - System 5 8271 DOS and Teletext Kernel
SYS5-1F.zip - System 5 8271 DOS and Kernel source, with switches for 40/80 VDU and disk speeds. vdu%=40, vdutrans%=TRUE, execsp%=TRUE builds the above ROM. Currently there are a couple of fixed address that, eg, the Econet ROM calls which have moved, that's the next tweek needed.

There was an archive of System ROMs posted a couple of weeks ago with names like JOSDOS, TANDOS, TOSDOS, etc. The only difference between each of those ROMs is the disk initialisation table to set the disk access speeds.

I really should get out of this habit of coding into the middle of the night. I start a 9-5 job on Monday which requires me leaving the house before 7:30!

Code: Select all

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

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

Re: Abasic2/3 and SBasic2/3

Post by jgharston » Sun Feb 04, 2018 2:37 am

Update, and probably finished:
SYS5-40.zip - System 5 8271 DOS and Teletext Kernel, teletext conversion now done on OSRDCH as well.
SYS5-1F.zip - System 5 8271 DOS and Kernel source, with switches for 40/80 VDU, teletext character conversion, disk speeds and SPOOL/EXEC optimisation.

From the documentation:
Updated SYSDOSnn ROM contains:
*SPOOL/*EXEC function as on the BBC. The handle is checked instead of
changing vectors, and *SPOOL/*EXEC without a filename close any currently
open SPOOL/EXEC file.

DiskNotReady from floppies is ignored, allowing easier use of 3.5" floppy
drives.

With a teletext display characters &23, &5F, &60 (# _ `) need to be stored
in screen memory as &5F, &60, &23. The SPOOL/EXEC update releases enough
space in SYSDOS40 to allow teletext character conversion on OSWRCH and
OSRDCH.

The startup display is 'Acorn DOS' in capitals as a visual reminder.

On startup, if there is code at &A000 that starts with a JSR (a &20 byte) it
is entered at &A000.

Code: Select all

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

Prime
Posts: 2554
Joined: Sun May 31, 2009 11:52 pm
Contact:

Re: Abasic2/3 and SBasic2/3

Post by Prime » Sun Feb 04, 2018 5:38 pm

Right, I've been merging the changes into my BeebASM version of the source, with a view to combining the 1770 disk routines form my Atom interface,
I may actually prototype with one of the Atom boards as they are essentially the same bus :)

Noticed one thing, the jump to EXEC a boot file in the block starting at LFF5E still points to the old exec address, if execsp is enabled won't this fail?

One thing I did wonder, you have several points in the code that are labeled as FIXED POINT, and you check for them being at fixed addresses, what is the reason behind this? Surely well behaved code should not be calling anything but known vectors directly, so as long as these point to the correct places then external code should be good to go? Or am I missing something?

Cheers.

Phill.

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

Re: Abasic2/3 and SBasic2/3

Post by jgharston » Sun Feb 04, 2018 10:18 pm

Prime wrote:Right, I've been merging the changes into my BeebASM version of the source, with a view to combining the 1770 disk routines form my Atom interface,
I may actually prototype with one of the Atom boards as they are essentially the same bus :)

Noticed one thing, the jump to EXEC a boot file in the block starting at LFF5E still points to the old exec address, if execsp is enabled won't this fail?
Ah, thanks for spotting this, I'll fix that. Quite a few gotchas in pre-BBC code where things jump directly to command routines instead of passing a command to OSCLI.
Prime wrote:One thing I did wonder, you have several points in the code that are labeled as FIXED POINT, and you check for them being at fixed addresses, what is the reason behind this?
Those are addresses called directly by the Econet ROM. The same problem with the Atom Econet utilities. Unless the Econet ROM is updated it will be jumping to those addresses expecting the code it expects to be there.
Prime wrote:Surely well behaved code should not be calling anything but known vectors directly,
Ha! Almost all pre-BBC code jumps directly to addresses buried within the Kernel, the DOS and the Econet ROM. Even quite a bit of early non-Acorn BBC code jumped directly into the middle of ROM code, causing it to crash and burn as soon as you try and use it on a different BASIC/MOS.

A thought that occured to be going to bed last night, the recreated source is from "System 5 Release 1F". The updated source really should have a different release code. I wondered if "1F" was a hex number, but the original file name calls it "version 1 release F", so I am tempted to call the updated code something like "version 1 release G".

Ideally, the release number should encode the FDC and the VDU type. "System 5 Release 1F" is the 8271 FDC and 80x25 VDU, "TOSDOS-S3" is the 8271 and 40x25 VDU, and is binary identical other than a dozen bytes for the 40x25 VDU. I've been initially saving the code as SYSDOS40 and SYSDOS80. Using the DFS version numbering system, 1x could be 8271 FDCs and 2x could be 1770 FDC, so SYS5-1G-40, SYS5-1G-80 for 8271 and SYS5-2G-40, SYS5-2G-80 for 1770.

Also, "System 5" is a bit of a misnomer, as all the System systems are essentially the same system, it's just the size of box and the collection of cards that gave them their name:
System 1 - bare CPU card
System 2 - single-height Eurocard case
System 3 - single-height Eurocard case with disk interface
System 4 - double-height Eurocard case
System 5 - one-and-a-half-height Eurocard

just like a "BBC Model B" is just a "BBC Model A" with more bits plugged in.

Code: Select all

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

Post Reply