Jump to content
Sign in to follow this  

Fast Rom Data Lookup For Small Arrays

Recommended Posts

Hi all,


In the old days (of pure asm) if you had a small byte data array you could write a subroutine which just added the array index to the program counter making it jump to a retlw which returned the data. Then make sure the whole routine was within one page (eg org 0x300).


The new general rom data lookup (rom char *x = "data":rolleyes: is great, but it has quite a big code overhead.


Maybe the compiler could optimise it for char arrays of less than 253 ish bytes.


At the moment I am trying to get round this by forcing the lookup subroutine into a single page by putting it in using #pragma DATA 0700, (raw code values); the calling it from a asm{} block in my code.

It would be a bit easyer if we could have a way of forcing a block of asm{} into a particular location.


What Im doing at the moment is..


char decode(char t)





movlw 0x0F

andwf _t, W

call 0x0700

movwf _t


return t;




#pragma DATA 0x0700, 0x0782, 0x343F, 0x340C, 0x345B, 0x345E, 0x346C, 0x3476, 0x3477, 0x341C, 0x347F, 0x347E, 0x347D,

0x3467, 0x3433, 0x344F, 0x3473, 0x3471;



This is intended to do a simple decode for a seven segment display (and its not been tested it yet !)



PS is this all BoostC related.

Share this post

Link to post
Share on other sites



The current implementation of rom data is total universal, it will work crossing codepage boundarys etc. It doesn't try to be minimalist which it could be in some cases.


Short strings (I think its less than 12 characters) are currently best left stored without the "rom".


Improving this is on the todo list, so you should see it in later versions.




Share this post

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...