Date : Sat, 23 Feb 2008 18:46:57 +0000
From : jgh@... (Jonathan Graham Harston)
Subject: BBC FPGA Boots to BASIC... almost...
Mark McDougall wrote:
> > to generate "No such variable" and see what happens.
> Same thing - I see "N" and it freezes...
>
> > *FX5,0
> > and then generate the Mistake error again.
> Same deal.
>
> I should mention that pressing <ESC> also hangs the machine. From the BASIC
> prompt I see "Esc" before it hangs...
Hmmm. Wonder if you've implemented BRK incorrectly. It should do:
PC=PC+2 (so PC points to the address of the BRK plus 2)
PSW = PSW OR &10 (setting B flag)
(SP) = PC DIV 256 (stack program counter)
SP = SP -1
(SP) = PC MOD 256
SP = SP -1
(SP) = PSW (stack flags)
SP = SP -1
PSW = PSW OR &04 (setting I flag, disabling IRQs)
I seem to remember getting BRK slightly wrong ages ago - setting
the flags all in one go, or pointing PC to BRK+1 instead of BRK+2,
can't exactly remember.
The only other thing I can think of is the code for OSBYTE 126
isn't working. Most languages acknowledge Escape if Escape is
detected, BASIC acknowledges any pending Escape on /all/ errors,
somethig like:
.ErrorHandler
JSR tidyup
LDA #&DA:JSR OSBYTE :\ Clear VDU queue
LDA #&7E:JSR OSBYTE :\ Ack. any Escape
PtrA=Error handler :\ Point to ON ERROR program code
JMP ExecutionLoop
ObSomething:
I've occasionally pondered why the recommended way for the IRQ
routine to determine if it's a hardware or software IRQ (ie BRK)
is to do:
PLA:AND #&10
which requires A to be preserved first, as in the BBC MOS:
.IRQHandler
STA &FC:PLA:AND #&10
As the BRK bit is set /before/ the flags are stacked, and
according to my documentation, is still set once the handler is
executing, wouldn't:
.IRQhandler
PHA:PHP:PLA:AND #&10
work, with the advantage of not needed a memory location to hold
A?
--
J.G.Harston - jgh@... - mdfs.net/User/JGH
Youth has now fled. Their best years have been passed in the service
of the party. They are ageing and their ideals have also passed,
dispersed by the contrarities of daily struggles.