Hi all,
I wanted to write a Utility ROM for use when developing my own projects. I soon realized that there are only a few books that cover this in the detail that I needed.
Therefore, to help others, I have put together a simple example of a ROM that handles the help and if called, executes one of the three commands that is built in it.
https://github.com/MadFly-Team/BBCMicro-Rom-Example
I have taken one of the BASIC examples in Bruce Smiths wonderful book 'Advanced Sideways RAM users guide', and converted and modified it to be in assembler, for building with Beebasm.
I have tested it on my BBC Master (switching to BBC-B, BBC-B+ and also MOS 3.2 and MOS 3.5). I also tested it in Beebem.
If you get the urge to clone and try it, I would love your feedback. Please bare in mine, I have only just created the repo and there is the first draft of the README.md.
thanks, Neil
Example 6502 source for creating a ROM.
Example 6502 source for creating a ROM.
---------------------------------------------------
We live for the one, we die for the one!
We live for the one, we die for the one!
Re: Example 6502 source for creating a ROM.
thks
BBC Model B: Aries B20 , Aries B12
BBC Master 128K: Pi Tube
CoPro 65C102, Replay Rom, ATPL ROM/RAM Brd, 2X 5.25 Drv
BBC Master 128K: Pi Tube
CoPro 65C102, Replay Rom, ATPL ROM/RAM Brd, 2X 5.25 Drv
Re: Example 6502 source for creating a ROM.
---------------------------------------------------
We live for the one, we die for the one!
We live for the one, we die for the one!
-
- Posts: 889
- Joined: Tue Aug 30, 2005 12:42 am
- Contact:
Re: Example 6502 source for creating a ROM.
Regarding the zero page useage - service ROMs aren't allowed to use the $00...$8f region - that area is reserved for the current language ROM. Smith's book describes $70...$8f as the "user area", but that's only true when using the BASIC ROM. Other language ROMs are not obliged to not use this for their own workspace. And anyway, even in the BASIC ROM case, it's still a bit rude, because the user of your ROM might be using this area for something themselves!
The hard-coded $38/$39 could go there as well - or, alternatively, push high byte of address-1 then low byte of address-1 onto the stack and do an RTS. Then no zero page required!
(If you still need more zero page, with care you can also use $b0...$bf, which is available for general use but may get overwritten by any filing system call. If you're not writing output (OSWRCH can make a filing system call when spooling!) or reading input (OSRDCH can make a filing system call when execing!) then this region can come in handy too.)
--Tom
$a8...$af would be a better region to use for TEMPPTRL, TEMPPTRH and TEMPSTORE.Master Reference Manual pt 1, pg F.6-1 wrote: &0000–&008F Language workspace.
Programs should not use this area of memory unless they are allowed to do so by the current language. Some languages make part of this page available to other programs (BASIC, for example, reserves locations &70 – &8F for the user) – but this is NOT guaranteed
The hard-coded $38/$39 could go there as well - or, alternatively, push high byte of address-1 then low byte of address-1 onto the stack and do an RTS. Then no zero page required!
(If you still need more zero page, with care you can also use $b0...$bf, which is available for general use but may get overwritten by any filing system call. If you're not writing output (OSWRCH can make a filing system call when spooling!) or reading input (OSRDCH can make a filing system call when execing!) then this region can come in handy too.)
--Tom
b2 BBC B/B+/Master emulator: https://github.com/tom-seddon/b2; BeebLink filing system: https://github.com/tom-seddon/beeblink; more BBC Micro stuff: https://github.com/tom-seddon?tab=repos ... :bbc-micro
Re: Example 6502 source for creating a ROM.
Brill Tom, I will change that, many thanks for reviewing and pointing out the hard coded references, I normally hate magic numbers, missed them. I am sure the 8 bytes at &a8 will be fine. Good call with pushing the high then low bytes to stack and RTS, it's been a while since I have done 8 bit coding.tom_seddon wrote: ↑Tue Mar 05, 2024 2:43 am Regarding the zero page useage - service ROMs aren't allowed to use the $00...$8f region - that area is reserved for the current language ROM. Smith's book describes $70...$8f as the "user area", but that's only true when using the BASIC ROM. Other language ROMs are not obliged to not use this for their own workspace. And anyway, even in the BASIC ROM case, it's still a bit rude, because the user of your ROM might be using this area for something themselves!
$a8...$af would be a better region to use for TEMPPTRL, TEMPPTRH and TEMPSTORE.Master Reference Manual pt 1, pg F.6-1 wrote: &0000–&008F Language workspace.
Programs should not use this area of memory unless they are allowed to do so by the current language. Some languages make part of this page available to other programs (BASIC, for example, reserves locations &70 – &8F for the user) – but this is NOT guaranteed
The hard-coded $38/$39 could go there as well - or, alternatively, push high byte of address-1 then low byte of address-1 onto the stack and do an RTS. Then no zero page required!
(If you still need more zero page, with care you can also use $b0...$bf, which is available for general use but may get overwritten by any filing system call. If you're not writing output (OSWRCH can make a filing system call when spooling!) or reading input (OSRDCH can make a filing system call when execing!) then this region can come in handy too.)
--Tom
Cheers, Neil
---------------------------------------------------
We live for the one, we die for the one!
We live for the one, we die for the one!