Writing a service rom - it's not recognized

bbc/electron apps, languages, utils, educational progs, demos + more
Post Reply
User avatar
roland
Posts: 4132
Joined: Thu Aug 29, 2013 9:29 pm
Location: Born (NL)
Contact:

Writing a service rom - it's not recognized

Post by roland » Sat May 16, 2020 9:42 pm

Now that I have submitted my ElkWifi board for production I am starting to write the accompanying service ROM. I took the example in the Electron Advanced User Guide as a start and wrote this:

Code: Select all

\ Sideway ROM for Electron Wifi board
\ (c) Roland Leurs, May 2020

oswrch = &FFEE
osasci = &FFE3
line = &F2          \ address for command line pointer

ORG &8000         ; it's a sideway ROM service

\ Rom header
.romstart           equb 0                      \ It's not a language ROM
                    equb 0
                    equb 0
                    jmp service                 \ Jump to service entry point
                    equb &82                    \ ROM type byte: service rom
                    equb (copyright-romstart)   \ Offset to copyright string
                    equb 0           
.romtitle           equb &A                     \ Title string
                    equs "Electron Wifi"
                    equb 0
.romversion         equs "0.01"                 \ Rom version string
                    equb &D
.copyright          equb 0                      \ Copyright message
                    equs "(c) 2020 Roland Leurs"
                    equb 0

\ Command table
.commands           equs "IFIW"                 \ Just a test

\ Service handling code, A=reason code, X=ROM ID, Y=data
.service            cmp #4                      \ is reason an unknown command?
                    beq command                 \ if so, go search for command
                    cmp #9                      \ is reason a cry for help?
                    beq help                    \ if so, show some help text
                    cmp #3                      \ is reason an autoboot call?
                    bne notboot                 \ if not then goto not boot
                    jmp autorun                 \ go to autorun (initialize)
.notboot            rts                         \ other reason, not for me, carry on

.command            tya                         \ save X and Y registers, we don't save the A because
                    pha                         \ the exit value of A depends on the command.
                    txa
                    pha
                    ldx #4                      \ command length, search pointer
.command_l1         lda (line),y                \ read next letter of command
                    cmp commands-1,x            \ compare with my command
                    bne command_l2              \ if not equal then it's not me
                    iny                         \ increment command pointer
                    dex                         \ decrement search pointer      
                    bne command_l1              \ read next character
                    beq wifi                    \ it's me, do something
.command_l2         pla                         \ restore registers
                    tax
                    pla
                    tay
                    lda #4                      \ restore reason code
                    rts                         \ pass on call

.help               tya                         \ save X and Y registers, we don't save the A because
                    pha                         \ the exit value of A depends on the command.
                    txa
                    pha
                    ldx #0                      \ load pointer
.help_l1            lda romtitle,x              \ load character
                    bne help_l2
                    lda #$20                    \ replace &00 character by a space
.help_l2            jsr osasci                  \ print the character
                    inx                         \ increment pointer
                    cmp #(copyright-romtitle)   \ test end of title
                    bne help_l2                 \ if not, get another character
                    pla                         \ restore registers
                    tax
                    pla
                    tay
                    lda #9                      \ restore reason code
                    rts                         \ pass on call

.autorun            rts                         \ not used at the moment

.wifi               lda #&2A                    \ Just print three stars
                    jsr osasci
                    jsr osasci
                    jsr osasci
                    lda #&D
                    jsr osasci
                    lda #&A
                    jsr osasci
                    pla
                    tax
                    pla
                    tay
                    lda #0                      \ claim the call
                    rts
                    
.romend             

SAVE "WIFIROM", romstart, romend
However, when I load the assembled code into BeebEm sideway ROM (or RAM) it is not recognized by the system. I expect to get an extra text string at *HELP and I expect three stars printed at *WIFI. But nothing happens :( When I look with the Megarom then I can see that the rom image is loaded.

What am I doing wrong here?
FPGAtom: 512 KB RAM, Real Time Clock and 64 colours
MAN WOMAN :shock:

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

Re: Writing a service rom - it's not recognized

Post by sweh » Sat May 16, 2020 10:23 pm

equs "(c) 2020 Roland Leurs"
Making a wild guess; shouldn't that be a capital C in "(C)" and not a lower case "(c)" ?

You can see if the ROM has been detected as a valid ROM by looking in ?(&2A1+slot)... at least on a Beeb, and I think the Elk uses the same location!
Rgds
Stephen

User avatar
jgharston
Posts: 4190
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: Writing a service rom - it's not recognized

Post by jgharston » Sat May 16, 2020 10:54 pm

Yep.

Also, you've got control codes in the ROM title and version string. That's going to impolitely kick in the goolies any utilities that attempt to access them.

ROM header is:
EQUB &vv ; either &ab for version a.bx or &ab for version ab.xx
EQUS "TITLE"
(optional
EQUB &00:EQUS "X.YZ"
or
EQUB &00:EQUS "X.YZ (dd MMM YYYY)"
)
EQUS "(C)"
EQUS "YYYY Author" if you don't have the date in the version string ("YYYY ...." not " YYYY.....")
EQUS "Author" if you do have the date in the version string
EQUB &00

No control codes, all zero-terminated printable ASCII, no null strings (ie if there's no version string, there's no version string, not EQUB 0 which is a null string).

In your example:

Code: Select all

\ Rom header
.romstart           equb 0                      \ It's not a language ROM
                    equb 0
                    equb 0
                    jmp service                 \ Jump to service entry point
                    equb &82                    \ ROM type byte: service rom
                    equb (copyright-romstart)   \ Offset to copyright string
                    equb &00                    \ version 0.0x
.romtitle           equs "Electron Wifi"
                    equb 0
.romversion         equs "0.01"                 \ Rom version string
.copyright          equb 0                      \ Copyright message
                    equs "(C)2020 Roland Leurs"
                    equb 0

Code: Select all

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

User avatar
jgharston
Posts: 4190
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: Writing a service rom - it's not recognized

Post by jgharston » Sat May 16, 2020 10:57 pm

sweh wrote:
Sat May 16, 2020 10:23 pm
You can see if the ROM has been detected as a valid ROM by looking in ?(&2A1+slot)... at least on a Beeb, and I think the Elk uses the same location!
The Electron swipes the carpet out from under your feet. It (and only it) uses &2A0+x.

Causes an annoying amount of needless IF Elk THEN thing ELSE otherthing.

Code: Select all

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

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

Re: Writing a service rom - it's not recognized

Post by sweh » Sun May 17, 2020 1:53 am

jgharston wrote:
Sat May 16, 2020 10:54 pm
EQUB &00:EQUS "X.YZ"
or
EQUB &00:EQUS "X.YZ (dd MMM YYYY)"
This isn't really so well defined. There are plenty of ROMs BITD that don't follow anything like this.
EQUS "YYYY Author" if you don't have the date in the version string ("YYYY ...." not " YYYY.....")
EQUS "Author" if you do have the date in the version string
Similarly, there's no real standard here, either.

Version string and copyright string are "free for all" areas.

You can even put control codes in (and ROMs BITD did) but, as you mention, it's not necessarily a good idea! What is permitted isn't always what is good :-)
Rgds
Stephen

User avatar
vanekp
Posts: 919
Joined: Thu Nov 30, 2000 7:09 am
Location: The Netherlands
Contact:

Re: Writing a service rom - it's not recognized

Post by vanekp » Sun May 17, 2020 10:44 am

Code: Select all

.help_l1            lda romtitle,x              \ load character
                    bne help_l2
                    lda #$20                    \ replace &00 character by a space
.help_l2            jsr osasci                  \ print the character
                    inx                         \ increment pointer
                    cpx #(copyright-romtitle)   \ test end of title
                    bne help_l1                 \ if not, get another character
There are also two errors here or else it print a constant strings of "E" (bne help_l1 not help_l2) and cpx cmp does a compare with the accumilator
Peter.

User avatar
roland
Posts: 4132
Joined: Thu Aug 29, 2013 9:29 pm
Location: Born (NL)
Contact:

Re: Writing a service rom - it's not recognized

Post by roland » Sun May 17, 2020 12:52 pm

Thanks for this information. I wasn't aware that the copyright string was that limited. I didn't see the errors in the *HELP routine because I didn't get that far :lol: I corrected the copy with your suggestions and it works now \:D/
Attachments
elk-wifi-rom.png
FPGAtom: 512 KB RAM, Real Time Clock and 64 colours
MAN WOMAN :shock:

User avatar
roland
Posts: 4132
Joined: Thu Aug 29, 2013 9:29 pm
Location: Born (NL)
Contact:

Re: Writing a service rom - no autoboot call

Post by roland » Sun May 17, 2020 1:45 pm

Now another question pops up ....

I want to initialize the hardware on boot time. So I wrote a short routine for the auto-boot call (reasoncode &03). But it looks like that my rom is never called with this reason code. In the service routine I added a small check:

Code: Select all

.service            cmp #4                      \ is reason an unknown command?
                    beq command                 \ if so, go search for command
                    cmp #9                      \ is reason a cry for help?
                    beq help                    \ if so, show some help text
                    cmp #3                      \ is reason an autoboot call?
                    bne notboot                 \ if not then goto not boot
                    sta &3001
                    jmp autorun                 \ go to autorun (initialize)
.notboot            rts                         \ other reason, not for me, carry on


So whenever the rom is called with reason code &03 the service entry writes &03 to address &3001. But this value is never written to this address so my best guess is that my rom is never called.

What is going wrong here?
FPGAtom: 512 KB RAM, Real Time Clock and 64 colours
MAN WOMAN :shock:

User avatar
0xC0DE
Posts: 800
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: Writing a service rom - it's not recognized

Post by 0xC0DE » Sun May 17, 2020 1:53 pm

A higher priority ROM has claimed it?
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my demos for Acorn Electron and BBC Micro

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

Re: Writing a service rom - it's not recognized

Post by sweh » Sun May 17, 2020 2:15 pm

If no key is pressed while doing a BREAK then the highest priority filesystem (DFS, ADFS) will likely have intercepted the call, done it's setup then set A=0. After all, only one file system should be able to autoboot.

If you want to do hardware initialization on every BREAK then I've found using service call 1 to be the easiest place. If you only want to initialise on power-on or ctrl-break then at the beginning of the service call do an OSBYTE fd,0,ff to get the break type
Rgds
Stephen

User avatar
roland
Posts: 4132
Joined: Thu Aug 29, 2013 9:29 pm
Location: Born (NL)
Contact:

Re: Writing a service rom - it's not recognized

Post by roland » Sun May 17, 2020 4:11 pm

0xC0DE wrote:
Sun May 17, 2020 1:53 pm
A higher priority ROM has claimed it?
sweh wrote:
Sun May 17, 2020 2:15 pm
If no key is pressed while doing a BREAK then the highest priority filesystem (DFS, ADFS) will likely have intercepted the call, done it's setup then set A=0. After all, only one file system should be able to autoboot.

Yes, this seems to be the cause. When I disable DFS in BeebEm then I get my message displayed. But this is not according the text in the advanced user guide:

Reason code &03: Auto-boot call

This call is issued during a reset to allow each service ROM to initialise itself. This enables the highest priority filing system to set up its vectors automatically rather than require explicit selection with a *command. To allow lower priority services to be selected the service ROM should examine the keyboard and initialise only if either no key is pressed or if its own ROM specific key is being pressed (e.g. D+BREAK for Acorn DFS). If the ROM initialises it should attempt to look for a boot file (typically !BOOT) to RUN, EXEC or LOAD if the Y register contains zero. This call is made during a reset after the start-up messages have been printed.

If DFS claims the call then other roms are not able to initialize any more. IMHO this is a bad behaviour of DFS.
sweh wrote:
Sun May 17, 2020 2:15 pm
If you want to do hardware initialization on every BREAK then I've found using service call 1 to be the easiest place. If you only want to initialise on power-on or ctrl-break then at the beginning of the service call do an OSBYTE fd,0,ff to get the break type
This works, however a message is printed before the regular banner(s). So my ROM starts now with

Wifi - device not found
BBC Computer
BASIC
>

Looks a bit funny, but it works :)
FPGAtom: 512 KB RAM, Real Time Clock and 64 colours
MAN WOMAN :shock:

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

Re: Writing a service rom - it's not recognized

Post by sweh » Sun May 17, 2020 4:34 pm

roland wrote:
Sun May 17, 2020 4:11 pm

Yes, this seems to be the cause. When I disable DFS in BeebEm then I get my message displayed. But this is not according the text in the advanced user guide:
It's not written clearly, but it is the expected behaviour. "To allow lower priority services...initialise only if ... no key is pressed" is the key part.
This works, however a message is printed before the regular banner(s). So my ROM starts now with

Wifi - device not found
BBC Computer
BASIC
>

Looks a bit funny, but it works :)
On a Beeb (dunno about an ELK) you can turn off the "BBC Computer" message during the service call with "OSBYTE A=D7,X=0,Y=7F", so you _could_ cheat and write your own :-) That's what my Manager ROM does to display "BBC Computer 160K" (however much SWRam was detected, plus the base memory).
Rgds
Stephen

User avatar
roland
Posts: 4132
Joined: Thu Aug 29, 2013 9:29 pm
Location: Born (NL)
Contact:

Re: Writing a service rom - it's not recognized

Post by roland » Sun May 17, 2020 5:19 pm

sweh wrote:
Sun May 17, 2020 4:34 pm
On a Beeb (dunno about an ELK) you can turn off the "BBC Computer" message during the service call with "OSBYTE A=D7,X=0,Y=7F", so you _could_ cheat and write your own :-) That's what my Manager ROM does to display "BBC Computer 160K" (however much SWRam was detected, plus the base memory).
According to the EAUG this call should also work on the Electron. I'll have a play with it. Thanks!
FPGAtom: 512 KB RAM, Real Time Clock and 64 colours
MAN WOMAN :shock:

User avatar
roland
Posts: 4132
Joined: Thu Aug 29, 2013 9:29 pm
Location: Born (NL)
Contact:

Re: Writing a service rom - it's not recognized

Post by roland » Sun May 17, 2020 7:10 pm

Looks all right to me :lol:
Electron-160K-Wifi.png
It's just some demo and test code, nothing real right now. But who knows within a few weeks......
FPGAtom: 512 KB RAM, Real Time Clock and 64 colours
MAN WOMAN :shock:

User avatar
roland
Posts: 4132
Joined: Thu Aug 29, 2013 9:29 pm
Location: Born (NL)
Contact:

Re: Writing a service rom - help

Post by roland » Sun May 17, 2020 9:49 pm

I now have several (dummy) commands implemented and the help function. Seems to work well so far :lol:
elk-wifi-help.png
Still demo code but the *HELP function works.

I always admired the way that the BBC Micro (and Electron) operating system works. But now that I am getting along with writing a service rom I get more and more respect for the way that this system is constructed. And that for the early 80's. The designers of this computer are really brilliant =D>
FPGAtom: 512 KB RAM, Real Time Clock and 64 colours
MAN WOMAN :shock:

User avatar
roland
Posts: 4132
Joined: Thu Aug 29, 2013 9:29 pm
Location: Born (NL)
Contact:

Re: Writing a service rom - displaying the acorn symbol

Post by roland » Sun Jun 28, 2020 8:30 pm

I have changed my banner to "Acorn Electron WiFi 160K".

I also want my Elk to beep and display this symbol at power on or CTRL+BREAK. I know there is an OSBYTE call to ask for the reset reason. But I don't know how to print the acorn symbol after this text?
FPGAtom: 512 KB RAM, Real Time Clock and 64 colours
MAN WOMAN :shock:

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

Re: Writing a service rom - it's not recognized

Post by BeebMaster » Sun Jun 28, 2020 9:30 pm

Is the Acorn symbol part of the Electron font? If so you can find its character code by copying it after

Code: Select all

PRINTASC(" 
followed by

Code: Select all

 ") 
whilst it's on screen and then use that ASCII value in your start-up message if a hard reset is detected.

I suppose you could also redefine it to look like a Wi-Fi symbol if the Wi-Fi is active.

It's unlikely to show up in Mode 7 as it isn't a Teletext character.
Image

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

Re: Writing a service rom - it's not recognized

Post by BeebMaster » Sun Jun 28, 2020 9:42 pm

The Acorn symbol doesn't look to be a standard defined character according to the Electron User Guide. Maybe it defines it temporarily during the start-up banner and sets it back to blank afterwards?
Image

User avatar
hoglet
Posts: 9624
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: Writing a service rom - it's not recognized

Post by hoglet » Sun Jun 28, 2020 9:54 pm

I believe the Acorn data lives here in the Electron MOS ROM:

Code: Select all

\ Electron Acorn bitmap for Ctrl-Break
\ ------------------------------------
.LC42B
EQUB &18:EQUB &3C:EQUB &3C:EQUB &7E
EQUB &7E:EQUB &00:EQUB &7E:EQUB &3C
\ ...**...
\ ..****..
\ ..****..
\ .******.
\ .******.
\ ........
\ .******.
\ ..****..
http://mdfs.net/System/ROMs/AcornMOS/El ... ELK100.zip

Dave

Coeus
Posts: 1900
Joined: Mon Jul 25, 2016 12:05 pm
Contact:

Re: Writing a service rom - it's not recognized

Post by Coeus » Sun Jun 28, 2020 10:11 pm

BeebMaster wrote:
Sun Jun 28, 2020 9:42 pm
The Acorn symbol doesn't look to be a standard defined character according to the Electron User Guide. Maybe it defines it temporarily during the start-up banner and sets it back to blank afterwards?
AFAIK the characters from the start-up banner are simply fed to OSWRCH so anything that can be drawn with VDU codes could be included.

That's not quite the same thing as putting control codes in ROM titles etc. where I can see JGH's point. Putting teletext codes in, for example, assumes people always use mode 7 so that's immediately wrong for an electron.

johnkenyon
Posts: 253
Joined: Wed Jul 20, 2011 3:21 pm
Location: Coventry
Contact:

Re: Writing a service rom - it's not recognized

Post by johnkenyon » Sun Jun 28, 2020 10:17 pm

hoglet wrote:
Sun Jun 28, 2020 9:54 pm
I believe the Acorn data lives here in the Electron MOS ROM:

Code: Select all

\ Electron Acorn bitmap for Ctrl-Break
\ ------------------------------------
.LC42B
EQUB &18:EQUB &3C:EQUB &3C:EQUB &7E
EQUB &7E:EQUB &00:EQUB &7E:EQUB &3C
\ ...**...
\ ..****..
\ ..****..
\ .******.
\ .******.
\ ........
\ .******.
\ ..****..
http://mdfs.net/System/ROMs/AcornMOS/El ... ELK100.zip

Dave
Search the source code for "Print Startup Banner" and you'll find

Code: Select all

\ Print startup banner
LDY #&02:JSR LDC34     :\ Print 'Acorn Electron' message
LDA &028D:BEQ LDA4D    :\ Soft Break, skip past
LDA #&07:JSR OSWRCH    :\ Beep
followed by the code that might do what you want:

Code: Select all

JSR LD6DE              :\ Store software cursor
JSR LCED5              :\ Copy Electron Acorn bitmap to cursor store
JSR LD6DE              :\ Restore software cursor to draw the Acorn bitmap

User avatar
hoglet
Posts: 9624
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: Writing a service rom - it's not recognized

Post by hoglet » Sun Jun 28, 2020 10:24 pm

Edit: posts crossed in the ether....

A bit more of the relvant reset code:
(starting about &DA38)

Code: Select all

\ Print startup banner
LDY #&02:JSR LDC34     :\ Print 'Acorn Electron' message
LDA &028D:BEQ LDA4D    :\ Soft Break, skip past
LDA #&07:JSR OSWRCH    :\ Beep
JSR LD6DE              :\ Store software cursor
JSR LCED5              :\ Copy Electron Acorn bitmap to cursor store
JSR LD6DE              :\ Restore software cursor to draw the Acorn bitmap
.LDA4D
LDY #&13:JSR LDC34     :\ Print Newlines
.LDA52
SEC:JSR LE87B          :\ Call Break Intercept Vector

Post Reply

Return to “8-bit acorn software: other”