thanks for the reply , unfortunatly i cant change the value of Event_Record_IDX in any routine , and still wanted to avoid allocating a new word varable
this solves the problem by making SDC_PAGE A WORD var
thanks for the reply , unfortunatly i cant change the value of Event_Record_IDX in any routine , and still wanted to avoid allocating a new word varable
this solves the problem by making SDC_PAGE A WORD var
Looks like you are correct.
The issue you see seems to be with the interim calculation for the assignment of SDC_PAGE.
SDC_PAGE = (Event_Record_IDX- nnn) when nnn is 255, 511 or 767.
The compiler seems to be generically testing the size of the variables during subtraction macro and letting you know that it is truncating the result of the interim step to a byte.
You can get around this as you indicated by changing the SDC_PAGE variable type to a word size or defining a new variable of size word to store the " Event_Record_IDX - nnn" calculation in before the assignment to SDC_PAGE.
E.G.
B0 var word
B0 = Event_Record_IDX - nnn
SDC_PAGE = B0
But this seems redundant.
BTW, I don't know if you realize this or not but your IF/Then statements that assign the value to SDC_PAGE do not all set the values from 0 to 255.
The first test for Event_Record_IDX < 256 obviously works because you are not manipulating anything, just a straight assignment.
But the following three tests for 256 to 511, 512 to 767 and 768 to 1023 actually set SDC_PAGE to 1 to 256.
If you want to set SDC_PAGE to 0 to 255 for each of these three blocks then you need to subtract 256, 512 and 768.
For instance...
If Event_Record_IDX = 256 then by doing SDC_PAGE = Event_Record_IDX - 255
Then SDC_PAGE = 256 - 255 = 1, not 0
If Event_Record_IDX = 513 then SDC_PAGE = Event_Record_IDX - 511 = 513 - 511 = 2, not 1, etc., etc.
I don't know if this is what you are intending, but it's just an observation.
Regards,
TABSoft
You know you can simplify the IF/Then test blocks (actually eliminate them) and just use 2 statements.
SDC_Block = (Current_Event * 4) - (3 - (Event_Record_IDX / 256))
SDC_PAGE = Event_Record_IDX - ((Event_Record_IDX / 256) * 256)
This will save you >100 code words or 194 bytes of code space.![]()
Regards,
TABSoft
Bookmarks