Running a Program from ROM / Sideways Rom

bbc/electron apps, languages, utils, educational progs, demos + more
Post Reply
DamoJay
Posts: 108
Joined: Sun Aug 05, 2012 11:10 pm
Contact:

Running a Program from ROM / Sideways Rom

Post by DamoJay »

Hi all,

Hopefully you can help an old man re-ignite his grey matter. I've got a Machine Code Program with the following attributes when you do a *INFO.

$.TEST 1A00 1A00 19FF 015

How can I go about loading this into Sideways Ram so I can execute the code by issuing a *TEST command ? Plan it to burn this into a physical EPROM at some point.

Thanks in advance for your help,

Damian.
User avatar
BeebMaster
Posts: 7420
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Running a Program from ROM / Sideways Rom

Post by BeebMaster »

Unless the file TEST is itself a fully-fledged ROM image (in which case it can be SRLOAD into sideways RAM) then it won't be easy to do this.

The program is set to load and run at &1A00 whereas sideways RAM and ROM is addressed from &8000 upwards. 6502 machine code isn't relocatable, except in a rare case where the only memory references are relative branches, so trying to run it from a different location won't work: all the jumps and loads and stores will operate on absolute memory addresses fixed when the code was assembled, which will be incorrect for a different load address.

If it alters any memory locations within the program then this won't work from sideways RAM as writing to sideways RAM locations is done in a completely different way to writing to main memory. And on ROM it will of course be read only anyway.

If you have the source code then you could rebuild it within a ROM image, with a ROM header, service code to implement an unknown * command and then the code itself.

If you don't have the source code then you could make it into a ROM Filing System image where it will appear as a file in the RFS which could then be *RUN at the original load/exec address.

The file length is &19FF, ie. 1 byte short of &2000 - is that correct, as it's very easy to get *SAVE wrong and miss off the last byte.
Image
User avatar
daveejhitchins
Posts: 7888
Joined: Wed Jun 13, 2012 6:23 pm
Location: Newton Aycliffe, County Durham
Contact:

Re: Running a Program from ROM / Sideways Rom

Post by daveejhitchins »

MakeRFS may be the one you want.

Dave H.
Available: ARA II : ARA III-JR/PR : ABR : AP5 : AP6 : ABE : ATI : MGC : Plus 1 Support ROM : Plus 3 2nd DA : Prime's Plus 3 ROM/RAM : Pegasus 400 : Prime's MRB : ARCIN32 : Cross-32
User avatar
sweh
Posts: 3325
Joined: Sat Mar 10, 2012 12:05 pm
Location: 07410 New Jersey
Contact:

Re: Running a Program from ROM / Sideways Rom

Post by sweh »

You can't easily run the program from the ROM. 6502 code normally isn't relocatable (if you have the source and can rebuilt it that's a different matter).

The standard solution for a "binary object" is to create a "wrapper" ROM that adds a new *TEST command and will copy the program stored in the ROM down to the normal load location and JMP to it.
Rgds
Stephen
DamoJay
Posts: 108
Joined: Sun Aug 05, 2012 11:10 pm
Contact:

Re: Running a Program from ROM / Sideways Rom

Post by DamoJay »

daveejhitchins wrote: Sun Jan 14, 2024 8:05 pm MakeRFS may be the one you want.

Dave H.
Thanks for this. I've created the ROMfile and loaded it into SWRam. I can see the Rom in there. But how do I then access the file on the ROM ? Is there any instructions on using MakeRFS ?

Thanks,

Damian.
User avatar
sweh
Posts: 3325
Joined: Sat Mar 10, 2012 12:05 pm
Location: 07410 New Jersey
Contact:

Re: Running a Program from ROM / Sideways Rom

Post by sweh »

DamoJay wrote: Mon Jan 15, 2024 1:44 pm Thanks for this. I've created the ROMfile and loaded it into SWRam. I can see the Rom in there. But how do I then access the file on the ROM ? Is there any instructions on using MakeRFS ?
The command "*ROM" switches to the ROM file system, and then you can use normal commands (eg *.) to see the contents. It's similar to tape, so "*OPT 1,2" before a "*." will show extended details.
Rgds
Stephen
Coeus
Posts: 3559
Joined: Mon Jul 25, 2016 12:05 pm
Contact:

Re: Running a Program from ROM / Sideways Rom

Post by Coeus »

The big question here is "Do you have the source code?"

If you do, although a service ROM has an additional layer of complexity over a simple assembler program, in that it needs a header and a routine to respond to a call for unrecognised commands, this is fairly simple stuff and JGH may even have a program that can generate something.

If you don't, then you have two options:
  • Put it in ROM for easy access but have it copied to the original location in memory when it needs to run. There are at least two ways to do this:
    • Use the ROM filing system as already mentioned. The advantage of that is that it is easier and there is a tool to automate it. It is probably also more tube-compatible. The disadvantage is the ROMFS is fairly slow and you need to selected it first, with *ROM, before you can run files from it.
    • Write a wrapper that copied the code from ROM down to its original location in RAM and which responds to the unrecognised ROM service call. That would execute faster and work even when DFS or TAPE was the selected filing system. If you wanted to support the tube, though, you'd have to go to some trouble to do that.
  • Disassemble it. There are number of disassemblers that will convert binary code back to a kind of source code with labels so it can be reassembled at a different address. Obviously you don't get the original comments and any labels are automatically generated but this can be a useful technique.
User avatar
davidb
Posts: 3400
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Running a Program from ROM / Sideways Rom

Post by davidb »

Being lazy, I haven't checked, but doesn't MakeRFS give you the option of creating a ROM that fast-loads the file into main RAM?
User avatar
daveejhitchins
Posts: 7888
Joined: Wed Jun 13, 2012 6:23 pm
Location: Newton Aycliffe, County Durham
Contact:

Re: Running a Program from ROM / Sideways Rom

Post by daveejhitchins »

davidb wrote: Mon Jan 15, 2024 5:36 pm Being lazy, I haven't checked, but doesn't MakeRFS give you the option of creating a ROM that fast-loads the file into main RAM?
It does . . . Dave H.
Available: ARA II : ARA III-JR/PR : ABR : AP5 : AP6 : ABE : ATI : MGC : Plus 1 Support ROM : Plus 3 2nd DA : Prime's Plus 3 ROM/RAM : Pegasus 400 : Prime's MRB : ARCIN32 : Cross-32
User avatar
jgharston
Posts: 5355
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: Running a Program from ROM / Sideways Rom

Post by jgharston »

Coeus wrote: Mon Jan 15, 2024 5:01 pm The big question here is "Do you have the source code?"
If you do, although a service ROM has an additional layer of complexity over a simple assembler program, in that it needs a header and a routine to respond to a call for unrecognised commands, this is fairly simple stuff and JGH may even have a program that can generate something.
MiniROM.src
Coeus wrote: Mon Jan 15, 2024 5:01 pm If you don't, then you have two options:
  • Put it in ROM for easy access but have it copied to the original location in memory when it needs to run. There are at least two ways to do this:
    • Use the ROM filing system as already mentioned. The advantage of that is that it is easier and there is a tool to automate it. It is probably also more tube-compatible. The disadvantage is the ROMFS is fairly slow and you need to selected it first, with *ROM, before you can run files from it.
MakeRFS
Coeus wrote: Mon Jan 15, 2024 5:01 pm [*]Write a wrapper that copies the code from ROM down to its original location in RAM and which responds to the unrecognised ROM service call. That would execute faster and work even when DFS or TAPE was the selected filing system. If you wanted to support the tube, though, you'd have to go to some trouble to do that.
ROMCommand

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.45
(C) Copyright J.G.Harston 1989,2005-2024
>_
DamoJay
Posts: 108
Joined: Sun Aug 05, 2012 11:10 pm
Contact:

Re: Running a Program from ROM / Sideways Rom

Post by DamoJay »

Thanks very one for their help.

Ok, I've had some success, but not 100% of what I'm trying to achieve. I've attached a SSD disk here, and on there are the following files :
  • TEST - this is the file that works from disk with *RUN TEST that I would like to create a *COMMAND ROM from. It's a test program by S. Cousins from 1984.

    RMCMND - this the ROMCOMMAND file for creating a *COMMAND Rom file , for a machine code program. I have tried this for the TEST file but get an error of "File 'TEST' is not I/O code".

    RMBASIC this the ROMBASIC file for creating a *COMMAND Rom file , for a machine code program. I have tried this for the TEST file but get an error of "Needs 6502 BASIC IV".

    MAKERFS - is the MAKERFS. I have successfully made a rom file (TESTROM) so I can do *ROM and then *RUN TEST. However no text of the rom when doing *H. and also no addition helpdesk when you do *H. RFS.

Would anyone be able to create a Rom Image that would have text appearing on *HELP and can be run directly with *TEST ?Would like to understand how to do this.

Many thanks in advance.

Damian.
Attachments
System Test ROM Build.ssd
(200 KiB) Downloaded 6 times
User avatar
jgharston
Posts: 5355
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: Running a Program from ROM / Sideways Rom

Post by jgharston »

It does indeed claim to want to run in the language processor, and not the I/O processor, so you will need to rewrite the code yourself from the source.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.45
(C) Copyright J.G.Harston 1989,2005-2024
>_
User avatar
tricky
Posts: 7718
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Running a Program from ROM / Sideways Rom

Post by tricky »

Is this just a case of making the load and exec addresses FFxxxx or is there something more?
DamoJay
Posts: 108
Joined: Sun Aug 05, 2012 11:10 pm
Contact:

Re: Running a Program from ROM / Sideways Rom

Post by DamoJay »

tricky wrote: Sun Jan 28, 2024 10:37 am Is this just a case of making the load and exec addresses FFxxxx or is there something more?
I'm not sure !! I think so, on the disc attached above, you just *RUN TEST and it works. I've managed to use MakeRFS and can run it by doing *ROM and then *RUN TEST. But would be great to create a rom that shows up with *H. and can be run with a command of *TEST.
User avatar
jms2
Posts: 3765
Joined: Mon Jan 08, 2007 6:38 am
Location: Derby, UK
Contact:

Re: Running a Program from ROM / Sideways Rom

Post by jms2 »

I had a go, and yes it seems that all you need to do is:

*LOAD TEST 1A00
*SAVE TEST FF1A00 +19FF

Then run RMCMND as usual and it works (takes quite a while though - I had to speed up BeebEm because I thought it had crashed!)

I tested the resultant rom and it appears in the *ROMS list and also responds to *HELP. However I couldn't get the actual command to work, because I was testing it on an emulated Master whereas it only runs on a BBC B. With a bit more fiddling about I think it would work.
Post Reply

Return to “8-bit acorn software: other”