Shop OBEX P1 Docs P2 Docs Learn Events
Logical FSR to FSR convertion — Parallax Forums

Logical FSR to FSR convertion

LemonLemon Posts: 34
edited 2005-01-10 02:59 in General Discussion
I am looking for a way to convert logical FSR values to physical FSR values and back.

At the moment I have a jumptable that converts :
$00 .. $1F - returns same value
$20 .. $2F -·returns $30 .. $3F
$30 .. $3F - returns $50 .. $5F
..etc.

With a·CALL, a JMP·and a·RET,·the operations spends·9 cycles, so what I am looking for is a <9 cycles code snippit that does the convertion.

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-01-09 20:34
    The following code converts a logical ram bank address
    into a physical address in fsr so you can use mov fr,indf
    or mov indf,fr to read/write a non-global rambyte

    mov fsr,w· ;w = logical address 0-127 for ram banks 0 to 7
    and w,#$70
    add fsr,w
    add fsr,#$10 ;bank 0 at $10, fsr points to ram byte
    You could at a $10 offset to include the global ram.

    regards peter
    ·
  • LemonLemon Posts: 34
    edited 2005-01-10 02:59
    Yup that seems to be the way to do it, thank you [noparse]:)[/noparse]
Sign In or Register to comment.