Routines in Zero Page

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.

User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Routines in Zero Page

Post by Twilighte »

Hi, i am wanting to put an irq routine in zero page and another one in page 1. Offcourse i cannot simply load directly into these pages because the loading routines may very well prohibit or rely on these locations.
So i will copy the code from the loaded area to pages 0 and 1. This is not a problem.
However, when compiling, XA will always assume i am compiling them in main memory, so all the STA's (self modified code) and JMP's (To zero page) will be wrong.

How do i achieve this?
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

After having done some experimentations, it appears that using the sections things does not work very well. So use .zero only for defining adresses in zero page.

For the code, I tried this, and it seems to work:

Code: Select all

  ; Some code here
SomeRoutine1
  lda foo
  sta bar
  rts

  ; Defines a label to mark the begining of the section to copy later
BaseCopyAdress

  ; Switch program counter to page 0
  *=$00
	
ZeroPageRoutine
  lda #$12
  lda #$13
  sta ZeroPageRoutine+1  ; This will use ZP adressing mode
ZeroPageRoutineEnd

 ; Switch program counter to page 1
 *=$100	
	
OnePageRoutine
  lda #$12
  lda #$13
  sta OnePageRoutine+1
OnePageRoutineEnd

  ; Move back the program counter to a usable adress
  ; by adding the size of the two previous routines to the
  ; label we defined before the program counter change.
  *=BaseCopyAdress+(ZeroPageRoutineEnd-ZeroPageRoutine)+(OnePageRoutineEnd-OnePageRoutine)

  ; Some more code here
SomeRoutine2
  lda foo
  sta bar
  rts
It's not particularly elegant, but it seems to work fine :)
User avatar
Twilighte
Game master
Posts: 819
Joined: Sat Jan 07, 2006 12:07 am
Location: Luton, UK
Contact:

Post by Twilighte »

Thats great, thanks Dbug.
Just one other question..
How do i allign code to a page boundary in xa? :P
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

Twilighte wrote:Thats great, thanks Dbug.
Just one other question..
How do i allign code to a page boundary in xa? :P

Code: Select all

.dsb 256-(*&255)
User avatar
Chema
Game master
Posts: 3014
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Post by Chema »

Dbug wrote:

Code: Select all

.dsb 256-(*&255)
Obfuscated XA :)

but that is the way I do it, as the .align directive does not seem to work.
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

Yes, I never managed to get it to work either, guess it was on my list of things to fix, but since the work-around was working... :)
Post Reply