Couple of BeebASM usage questions.

Development tools discussion area.
Post Reply
Prime
Posts: 2495
Joined: Sun May 31, 2009 11:52 pm
Contact:

Couple of BeebASM usage questions.

Post by Prime » Thu Feb 15, 2018 9:37 am

Hi all,

Some background on what I want to achieve......

I've been working on converting the disassembled Acorn System ROM to work with a 177x disk controller rather than the 8271. That bit is mostly done and I can now load programs from disk and run them correctly. However as the System dos rom is only 4K, like the Atom and original DFS it doesn't have things like Format and compact built in.

For Format I can convert the source from my AtomDOS board and assemble it as a loaded from disk program. I'll need to disassemble & convert compact and the other utilities but that should not be too much of a problem.

However what would be usefull is if there where a way of exporting the symbols that where defined whilst assembling the DOS rom so that the code for format/compact etc could then have access to them.

For compact this could be done by including it's code to be assembled and saved seperately. However with format I want to be able to produce 40 and 80 track versions from the same code, which would mean including the format code twice, and re-defining the number of tracks (which I don't think you can do as thins are read only once defined).

Final part is that I'll need to put the assembled files for FORM40, FORM80, COMPACT etc on a single disk image that can be transferred to a real disk for use, I know it is possible to drop a single file on a DFS image is it possible to add files to an already existing image? Also is it possible to set the qualifier when writing the image, as the Atom & System use space rather than $.

Cheers.

Phill.

User avatar
tricky
Posts: 2440
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: Couple of BeebASM usage questions.

Post by tricky » Thu Feb 15, 2018 1:32 pm

There is a command line option to export the symbols, I think in swift format, it's easily posted, I do this to export so that beebem, load them for debugging.

You can save multiple files by having multiple SAVE statements or by using the template option to load a disc image and then add to it, this is what I use for assembling, processing and then adding to a later compile.

Files are saved in $ by default, I'm not sure how you change that, but to rearrange files in an SSD, I used to load the image in beebem and then use the windows paste option to "script" processing file names.

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

Re: Couple of BeebASM usage questions.

Post by jgharston » Thu Feb 15, 2018 1:45 pm

tricky wrote:Files are saved in $ by default, I'm not sure how you change that, but to rearrange files in an SSD, I used to load the image in beebem and then use the windows paste option to "script" processing file names.
Does BeebAsm support, eg SAVE "a.file" if so would SAVE ".file" do it?

Code: Select all

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

SteveF
Posts: 508
Joined: Fri Aug 28, 2015 8:34 pm
Contact:

Re: Couple of BeebASM usage questions.

Post by SteveF » Thu Feb 15, 2018 10:30 pm

Prime wrote:Final part is that I'll need to put the assembled files for FORM40, FORM80, COMPACT etc on a single disk image that can be transferred to a real disk for use, I know it is possible to drop a single file on a DFS image is it possible to add files to an already existing image?
tricky already answered this, but I didn't notice and I wrote a mini example so I'll post this anyway. :-) You should be able to do this using the '-di' option - there's some detail on it in about.txt. However, depending on what you're trying to do, you may be able to simply have a single source file which does something like:

Code: Select all

ORG &2000
.form40
LDA #42
\blah blah
RTS
.end_form40
SAVE "FORM40", form40, end_form40
CLEAR &0000,&FFFF
ORG &2000
.compact
LDA #43
\ blah blah
RTS
.end_compact
SAVE "COMPACT", compact, end_compact
You could split that up into a series of INCLUDE files instead of writing everything in one big file, of course.

ETA: It might be a good idea to put each command in its own scope ("{" and "}" delimiters) so that you don't accidentally jump to a label in "FORM40" from within the "COMPACT" code, or something like that.
Prime wrote:Also is it possible to set the qualifier when writing the image, as the Atom & System use space rather than $.
If Jonathan's suggestion doesn't work, we could consider adding explicit support for this - although I guess the resulting SSD wouldn't be valid on a BBC. Perhaps we could add a '--atom' command line option to change the validation rules?
Last edited by SteveF on Thu Feb 15, 2018 10:48 pm, edited 1 time in total.

SteveF
Posts: 508
Joined: Fri Aug 28, 2015 8:34 pm
Contact:

Re: Couple of BeebASM usage questions.

Post by SteveF » Thu Feb 15, 2018 10:47 pm

Prime wrote:For compact this could be done by including it's code to be assembled and saved seperately. However with format I want to be able to produce 40 and 80 track versions from the same code, which would mean including the format code twice, and re-defining the number of tracks (which I don't think you can do as thins are read only once defined).
If you use the '-di' template based approach you can obviously make this work that way.

It might not be pretty, but you could also put the entire format code inside a single macro, and then instantiate that macro twice, if you'd prefer to have a single simple beebasm file which builds the entire SSD.

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

Re: Couple of BeebASM usage questions.

Post by jgharston » Fri Feb 16, 2018 1:47 am

SteveF wrote:If Jonathan's suggestion doesn't work, we could consider adding explicit support for this - although I guess the resulting SSD wouldn't be valid on a BBC. Perhaps we could add a '--atom' command line option to change the validation rules?
It works on a BBC, you do *DIR " "

Ideally, you shouldn't impose /any/ rules on the filenames you write out, that's entirely the choice of the programmer. If they want to write invalid filenames to the disk image, that's their choice, you shouldn't impose your opinions on what they want to do. If the programmer wants a disk image with a file called "*.*******" you should let them. You can't read their mind and decide that they have a reason for doing this, so you should just not impose your views on them in the first place.

Code: Select all

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

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

Re: Couple of BeebASM usage questions.

Post by jgharston » Fri Feb 16, 2018 2:40 am

Checking the source, SAVE does not impose any rules on the parsed filename, just stores it in a variable, and later on the code that saves to a disk image does something like:
dir ='$'
if filename[1]='.' then dir=filename[0]; filename=filename[2...];
filename=left(filename+padding,7);

so, SAVE " .name" should save a file called "name" in the directory (Atom/System qualifier) " ".

Code: Select all

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

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

Re: Couple of BeebASM usage questions.

Post by Prime » Sun Feb 18, 2018 3:39 pm

Just a small update, not got to solving the disk writing yet.....

But for the format/verify code I have done the following :

Since BeebASM will let you assemble multiple things in the same block of 64K I simply included the rom code when assembling format, so that it is also assembled and it's symbols generated, that way format can access them without problems. The rom code has a save statement at the end that is surrounded by an an if so that it only actually saves the code when it is being assembled seperately. Thus :

Code: Select all

if (ISROM)
  if(SYS40)
    save "rom\sys5-1770-40.rom",start,end,entry
  else
    save "rom\sys5-1770-80.rom",start,end,entry
  endif
endif
I'm using the _tom branch of BeebASM so I can use -DISROM=1 on the command line when assembling the ROM, and -DISROM=0 when assembling format.
It's actually as shame that if doesn't default to 0 if a variable is not defined, though this of course may break other things, this is where ifdef would be handy :)

So now my makefile will spit out the 40 and 80 column versions of the main rom, and the 40 and 80 track versions of FORM and VERIFY.

Now to figure out writing them to disk....

Cheers.

Phill.

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

Re: Couple of BeebASM usage questions.

Post by jgharston » Sun Feb 18, 2018 4:21 pm

That's why we need ifdef/ifndef so we can do things like:
ifndef ISROM
ISROM=0 ; Default to not building a ROM
endif

or even
ifdef ISROM
ifdef SYS40
save "rom\sys5-1770-40.rom",start,end,entry
else
save "rom\sys5-1770-80.rom",start,end,entry
endif
endif

Adding ifdef/ifndef to AsmPDP made a whole sweep of things a lot easier to do.

Code: Select all

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

User avatar
sweh
Posts: 1919
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: Couple of BeebASM usage questions.

Post by sweh » Sun Feb 18, 2018 5:46 pm

jgharston wrote:That's why we need ifdef/ifndef so we can do things like:
ifndef ISROM
ISROM=0 ; Default to not building a ROM
endif
I believe this can be done with the proposed

Code: Select all

ISROM =? 0
syntax
Rgds
Stephen

User avatar
tricky
Posts: 2440
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: Couple of BeebASM usage questions.

Post by tricky » Sun Feb 18, 2018 6:09 pm

I have a build.bat that does this in a subroutine with parameters:

Code: Select all

if exist copy.ssd del copy.ssd
ren game.ssd copy.ssd
..\tools\beebasm.exe -i game.asm -di copy.ssd -do game.ssd
Whatever game.ssd SAVEs will be added to game.ssd.

I use this to build the self extracting compressed ROMs that the newest versions of my games ship as.
I also PRINT values from one assemble that will be saved and passed back in to a later one.

Code: Select all

echo.ORG ^&8000 >build.asm
echo.load = !load! >build.asm
echo.exec = !exec! >>build.asm
echo..data >>build.asm
type game_hdr.asm >>build.asm
echo.PRINT P%%-^&8000 >>build.asm
echo.SAVE "hdr", ^&8000, P%%, ^&8000 >>build.asm
..\tools\beebasm.exe -i build.asm -do game.ssd
I think there was some issue with INCLUDE, so I type the file, appending it to build.asm
The PRINT will be picked up and used later (by the actual call to beebasm which uses a DOS FOR loop to capture the output)
!load! evaluates to the current value of the environment variable load.
echo. prints the text and values following the .
> creates or empties a file and fils it with the text printed followed by a CR/LF (whatever windows is).
>> appends the text printed to the file followed by a CR/LF.

The actual build converts quite a few audio files, compresses the game and some of the audio and packages it all in a few seconds.

I have attached my "build script" for the very curious! :roll:
I'm sure it could be done in about 5 lines of make or 1 line of Perl, but I never really got past DOS :lol:

EDIT: Yes, I did get a bit lazy and copied and pasted stuff!
My Centipede build script is:

Code: Select all

..\Tools\beebasm.exe -i game.asm -opt 3 -do game.ssd -boot game
So I do know how to KISS :oops:
Attachments
build_game.zip
Not for the faint of heart!
(1.27 KiB) Downloaded 7 times

Post Reply