Argument out of range - how to find what is causing it?


Closed Thread
Results 1 to 6 of 6
  1. #1

    Default Argument out of range - how to find what is causing it?

    I have a long program (35000 bytes) in a PIC18F4620. During compile it throws up a warning of 'argument out of range'. I can search the .lst file and get the message shown below.
    AFAIK it is treating DEBUG as a word value, for example, .....if ((DEBUG) < ($ - 3ffh)).........

    How can I find out where in my PBP code the problem lies?

    I tried re-declaring all BYTES as WORDS. That did nothing.
    I tried re-declaring all WORDS as LONGS. That did nothing.

    Part of the 3662 page .LST file follows.

    Any suggestions gratefully received.
    BrianT


    LOC OBJECT CODE LINE SOURCE TEXT
    VALUE

    M else
    M if ((DEBUG) < ($ - 3ffh))
    001C34 EC28 F000 M call DEBUG
    M else
    M rcall DEBUG
    M endif
    M endif
    M endif
    M endif
    02250 DEBUG?C 035h
    001C38 0E35 M movlw 035h
    M L?CALL DEBUG
    M RST?RP
    M if (PREV_ALT != 0)
    M bcf WDTCON, ADSHR
    M PREV_ALT = 0
    M endif
    M if (PREV_BANK != 0)
    M movlb 0
    M PREV_BANK = 0
    M endif
    M
    M ifdef USE_LINKER
    M call DEBUG
    M else
    M if ((DEBUG) < 1)
    M call DEBUG
    M else
    M if ((DEBUG) > $)
    M call DEBUG
    M else
    M if ((DEBUG) < ($ - 3ffh))
    001C3A EC28 F000 M call DEBUG
    M else
    M rcall DEBUG
    M endif
    M endif
    M endif
    M endif
    02251 DEBUG?C 039h
    001C3E 0E39 M movlw 039h
    M L?CALL DEBUG
    M RST?RP
    M if (PREV_ALT != 0)
    M bcf WDTCON, ADSHR
    M PREV_ALT = 0
    M endif
    M if (PREV_BANK != 0)
    M movlb 0
    M PREV_BANK = 0
    M endif
    M
    M ifdef USE_LINKER
    MPASM 5.42 SEQUENCER VER BM 26 OCTOBER 2011 11-2-2011 15:19:37 PAGE 702


    LOC OBJECT CODE LINE SOURCE TEXT
    VALUE

    M call DEBUG
    M else
    M if ((DEBUG) < 1)
    M call DEBUG
    M else
    M if ((DEBUG) > $)
    M call DEBUG
    M else
    M if ((DEBUG) < ($ - 3ffh))
    001C40 EC28 F000 M call DEBUG
    M else
    M rcall DEBUG
    M endif
    M endif
    M endif
    M endif
    02252 DEBUG?C 038h
    001C44 0E38 M movlw 038h
    M L?CALL DEBUG
    M RST?RP
    M if (PREV_ALT != 0)
    M bcf WDTCON, ADSHR
    M PREV_ALT = 0
    M endif
    M if (PREV_BANK != 0)
    M movlb 0
    M PREV_BANK = 0
    M endif
    M
    M ifdef USE_LINKER
    M call DEBUG
    M else
    M if ((DEBUG) < 1)
    M call DEBUG
    M else
    M if ((DEBUG) > $)
    M call DEBUG
    M else
    M if ((DEBUG) < ($ - 3ffh))
    001C46 EC28 F000 M call DEBUG
    M else
    M rcall DEBUG
    M endif
    M endif
    M endif
    M endif
    02253 DEBUG?C 0051Eh
    Warning[202]: Argument out of range. Least significant bits used.
    001C4A 0E1E M movlw 0051Eh
    M L?CALL DEBUG
    M RST?RP
    M if (PREV_ALT != 0)
    M bcf WDTCON, ADSHR
    MPASM 5.42 SEQUENCER VER BM 26 OCTOBER 2011 11-2-2011 15:19:37 PAGE 703

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Argument out of range - how to find what is causing it?

    Take a look at your DEBUG statements.

    It looks like one of them is printing a string that contains "598" followed by an invalid character or value ($51E).
    You can see it in the macro calls ...

    02250 DEBUG?C 035h
    02251 DEBUG?C 039h
    02252 DEBUG?C 038h
    02253 DEBUG?C 0051Eh

    The offending character/constant is from line 2253 in the .asm file.
    And above that point in the asm file, you should see the debug line that contains the error (it will be commented).
    Find that line in your original source code, and you should see the problem.
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Argument out of range - how to find what is causing it?

    Thanks Darrel,
    My .asm file has no line numbers so I opened a new file in MCSPX then copied and pasted the .asm file to the blank MCSPX file via NotePad. This gave me line numbering and sure enough the PBP statement prior to line 2253 showed the problem.

    ; C:\PWEE2011\10OCT2011\SEQUENCER VER BM 26 OCTOBER 2011_BU\SEQUENCER VER BM 26 OCTOBER 2011.PBP 00733 debug 13, 10, "598", 1310
    DEBUG?C 00Dh
    DEBUG?C 00Ah
    DEBUG?C 035h
    DEBUG?C 039h
    DEBUG?C 038h
    DEBUG?C 0051Eh

    In the snip above,
    00733 debug 13, 10, "598", 1310
    is corrupted.

    The 00733 refers to the MCSPX line number. The 1310 should be 03, 10 for a <cr><lf>.
    A quick correction to line 733 in the PBP file then did the trick.

    Thanks again Darrel for fabulous service. I hope you are writing a book on issues like these which are baffling to a PBP user who does not understand the subtle points of assembler.

    Cheers
    Brian

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: Argument out of range - how to find what is causing it?

    There is a simpler way.
    All the necessary information is in the .LST file. You need to search for "Argument out of range" and then scroll up many pages until you find the PBP statement that caused the problem.

    02247 ; C:\PWEE2011\10OCT2011\SEQUENCER VER BM 26 OCTOBER 2011_BU\SEQUENCER VER BM 26 OCTOBER 2011_111102_1512
    00.PBP 00733 debug 13, 10, "598", 1310 The text in red is the offending PBP statement at line 733 in the MCSPX file.
    02248 DEBUG?C 00Dh
    001F04 0E0D M movlw 00Dh
    M L?CALL DEBUG
    M RST?RP
    M if (PREV_ALT != 0)
    M bcf WDTCON, ADSHR
    M PREV_ALT = 0
    M endif
    M if (PREV_BANK != 0)
    M movlb 0
    M PREV_BANK = 0
    M endif
    M
    M ifdef USE_LINKER
    M call DEBUG
    M else
    M if ((DEBUG) < 1)
    M call DEBUG
    M else
    M if ((DEBUG) > $)
    M call DEBUG
    M else
    M if ((DEBUG) < ($ - 3ffh))
    001F06 EC28 F000 M call DEBUG
    M else
    M rcall DEBUG
    M endif
    M endif
    M endif
    M endif
    02249 DEBUG?C 00Ah
    001F0A 0E0A M movlw 00Ah
    M L?CALL DEBUG
    M RST?RP
    MPASM 5.42 SEQUENCER VER BM 26 OCTOBER 2011 11-3-2011 10:21:09 PAGE 786


    LOC OBJECT CODE LINE SOURCE TEXT
    VALUE

    M if (PREV_ALT != 0)
    M bcf WDTCON, ADSHR
    M PREV_ALT = 0
    M endif
    M if (PREV_BANK != 0)
    M movlb 0
    M PREV_BANK = 0
    M endif
    M
    M ifdef USE_LINKER
    M call DEBUG
    M else
    M if ((DEBUG) < 1)
    M call DEBUG
    M else
    M if ((DEBUG) > $)
    M call DEBUG
    M else
    M if ((DEBUG) < ($ - 3ffh))
    001F0C EC28 F000 M call DEBUG
    M else
    M rcall DEBUG
    M endif
    M endif
    M endif
    M endif
    02250 DEBUG?C 035h
    001F10 0E35 M movlw 035h
    M L?CALL DEBUG
    M RST?RP
    M if (PREV_ALT != 0)
    M bcf WDTCON, ADSHR
    M PREV_ALT = 0
    M endif
    M if (PREV_BANK != 0)
    M movlb 0
    M PREV_BANK = 0
    M endif
    M
    M ifdef USE_LINKER
    M call DEBUG
    M else
    M if ((DEBUG) < 1)
    M call DEBUG
    M else
    M if ((DEBUG) > $)
    M call DEBUG
    M else
    M if ((DEBUG) < ($ - 3ffh))
    001F12 EC28 F000 M call DEBUG
    M else
    M rcall DEBUG
    M endif
    MPASM 5.42 SEQUENCER VER BM 26 OCTOBER 2011 11-3-2011 10:21:09 PAGE 787


    LOC OBJECT CODE LINE SOURCE TEXT
    VALUE

    M endif
    M endif
    M endif
    02251 DEBUG?C 039h
    001F16 0E39 M movlw 039h
    M L?CALL DEBUG
    M RST?RP
    M if (PREV_ALT != 0)
    M bcf WDTCON, ADSHR
    M PREV_ALT = 0
    M endif
    M if (PREV_BANK != 0)
    M movlb 0
    M PREV_BANK = 0
    M endif
    M
    M ifdef USE_LINKER
    M call DEBUG
    M else
    M if ((DEBUG) < 1)
    M call DEBUG
    M else
    M if ((DEBUG) > $)
    M call DEBUG
    M else
    M if ((DEBUG) < ($ - 3ffh))
    001F18 EC28 F000 M call DEBUG
    M else
    M rcall DEBUG
    M endif
    M endif
    M endif
    M endif
    02252 DEBUG?C 038h
    001F1C 0E38 M movlw 038h
    M L?CALL DEBUG
    M RST?RP
    M if (PREV_ALT != 0)
    M bcf WDTCON, ADSHR
    M PREV_ALT = 0
    M endif
    M if (PREV_BANK != 0)
    M movlb 0
    M PREV_BANK = 0
    M endif
    M
    M ifdef USE_LINKER
    M call DEBUG
    M else
    M if ((DEBUG) < 1)
    M call DEBUG
    M else
    M if ((DEBUG) > $)
    MPASM 5.42 SEQUENCER VER BM 26 OCTOBER 2011 11-3-2011 10:21:09 PAGE 788


    LOC OBJECT CODE LINE SOURCE TEXT
    VALUE

    M call DEBUG
    M else
    M if ((DEBUG) < ($ - 3ffh))
    001F1E EC28 F000 M call DEBUG
    M else
    M rcall DEBUG
    M endif
    M endif
    M endif
    M endif
    02253 DEBUG?C 0051Eh
    Warning[202]: Argument out of range. Least significant bits used. Search for this first then scroll up until you find the offending PBP statement.

  5. #5
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: Argument out of range - how to find what is causing it?

    I think that this causing overflow:
    DEBUG 13,10, "598", 1310
    Comma is missing.
    So DEBUG can handle only byte, so 1310 = $51E and that is bigger then 1 byte.
    So i suppose that DEBUG should be something like this
    DEBUG 13,10, "598", 13,10
    Just find in PBP 1310, and insert comma...
    EDIT: I just read first few post's

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Argument out of range - how to find what is causing it?

    Food for thought ...

    You can open .LST and .ASM files in MicroCode Studio, and it even highlights them.
    If you have line numbers turned on, View > Editor Options > General tab > Show line numbers in left gutter
    It's easy to find things according to the numbers in the error messages.

    When opening a file in MCS, change the Files of type: dropdown box to Assembler and List Files (*.asm;*.lst)

    Select the View > Editor Options > General tab > Prompt if file reload required option and it will ask to reload the files after a compile of the .pbp program so you're always looking at the most recent version.
    DT

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