BRK and xa

Questions, bug reports, features requests, ... about the Oric Software Development Kit. Please indicate clearly in the title the related element (OSDK for generic questions, PictConv, FilePack, XA, Euphoric, etc...) to make it easy to locate messages.

jede
Flying Officer
Posts: 191
Joined: Tue Mar 14, 2006 11:53 am
Location: France

BRK and xa

Post by jede »

Hello,

In telestrat, F. Broche used a tricky think to manage routines vectors a kind of software interrupt on PC

Anyway, it's not possible to use it in xa because it's a bit cheat (it's not how the opcode works)

ex : brk $10 ; does not work because brk is a one byte opcode

It there a way to have xa working with this syntax, except doing :

.byt $00,$10

How it works :

$c000 brk $10

6502 push program counter +2 (when it use brk):

stack :
$02
$c0
P

F. Broche do that :

"dec $1XX,x" in stack the value $02

in stack he have now the adress of brk parameter. He can read it and jump to his subroutine indexed from this value

The only way to manage subroutine approximately like this, is only available on 65C816 : with jsr (...,X). jsr is better because F. Broche's trick use some cycles to have brk working in this way

In french :
===============
* Du livre Telestrat système m'était conté :

TRAITEMENT DU BRK
Principe : Trivial mais o combien génial ! Seul un farfelu comme BROCHE pouvait y penser.
L'appel à une routine du moniteur se fait non pas par des JMP mais par le BRK qui
pour l'occasion devient une instruction page 0.
Voici le principal :
- Après un BRK, donc à l'entrée de la routine, la pile contient dans l'ordre d'entrée
PC+2 (PC est l'adresse exacte du BRK) et P.
- On dépile P que l'on sauve car on en aura besoin pour le RTI.
- On enlève 1 à l'adresse de retour de l'IRQ, donc il y a dans la pile PC+1. C'est en
PC+1 que le code de la routine se trouve, on le lit.
- On empile l'adresse de retour du BRK décrémentée de 1.
- On empile l'adresse exacte de la routine.
- Et on empile P.
===============