Getting around asm - argument out of range - error


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: Getting around asm - argument out of range - error

    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

  2. #2
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229


    Did you find this post helpful? Yes | No

    Default Re: Getting around asm - argument out of range - error

    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

  3. #3
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229


    Did you find this post helpful? Yes | No

    Default Re: Getting around asm - argument out of range - error

    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

Similar Threads

  1. Replies: 7
    Last Post: - 27th December 2012, 22:42
  2. Missing Operator ASM error
    By retepsnikrep in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th June 2012, 08:26
  3. Argument out of range - how to find what is causing it?
    By BrianT in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd November 2011, 03:00
  4. MASM error 202 argument out of range
    By retepsnikrep in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 29th October 2011, 10:14
  5. Undefined Symbol error when using ASM interrupt
    By toalan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th January 2005, 22:41

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts