displaying #v as hex value in MPASM

Enhanced mid-range devices. PIC12F1xxx and PIC16F1xxx

displaying #v as hex value in MPASM

Postby SeanD » Wed Sep 24, 2014 12:46 pm

PIC forum current not letting me post so will try here. I am writing a dim macro to overcome issues such as 151 errors and to keep track of array sizes (I will probably add some 'typing' at a later stage such as int, uint int16 etc). Below is an example of filling up some memory and the macro. I am using #v to display the allocated memory locations for the enhanced 14-bit core PICs. I'm pretty sure I have it debugged, but it would be much much easier if the memory locations were displayed in hex. I can probably write a dec to hex macro, but it may already have been done. Has anyone written such a macro - most search tools make it very difficult to search for #v so I apologise in advance if this is a simple task.
Sean
Code: Select all
PIC forum current not letting me post so will try here. I am writing a dim macro to overcome issues such as 151 errors. Below is an example of filling up some  memory and the macro. I am using #v to display the allocated memory locations. I'm pretty sure I have it debugged and can probably write a dec to hex macro

#include<m16f1847.inc>
    dim ara0,     .10    ;10 bytes in shared memory from memory location: decimal 112 to 121
    dim ara1,     .04    ; 4 bytes in shared memory from memory location: decimal 122 to 125
    dim ara2,     .74    ;74 bytes in bank0  from memory location: decimal   32 to 105
    dim ara3,     .67    ;67 bytes in bank1  from memory location: decimal  160 to 226
    dim ara4,     .80    ;80 bytes in bank2  from memory location: decimal  288 to 367
    dim ara5,     .08    ; 8 bytes in bank3  from memory location: decimal  416 to 423
    dim ara6,     .01    ; 1 bytes in bank3  from memory location: decimal  424 to 424
    dim ara7,     .02    ; 2 bytes in bank3  from memory location: decimal  425 to 426
    dim ara8,     .79    ;79 bytes in bank4  from memory location: decimal  544 to 622
    dim ara9,     .40    ;40 bytes in bank5  from memory location: decimal  672 to 711
    dim arab10,   .40    ;40 bytes in bank5  from memory location: decimal  712 to 751
    dim arab11,   .01    ; 1 bytes in bank6  from memory location: decimal  800 to 800
    dim arab12,   .80    ;80 bytes in bank7  from memory location: decimal  928 to 1007
    dim arab13,   .80    ;80 bytes in bank8  from memory location: decimal 1056 to 1135
    dim arab14,   .80    ;80 bytes in bank9  from memory location: decimal 1184 to 1263
    dim arab15,   .80    ;80 bytes in bank10 from memory location: decimal 1312 to 1391
    dim arab16,   .80    ;80 bytes in bank11 from memory location: decimal 1440 to 1519
    dim arab17,   .48    ;80 bytes in bank12 from memory location: decimal 1568 to 1615

    code 0
    nop
    end


;Macro here:

;----------------------------------------------------
; dim
; reserves memory starting with shared memory and then bank0, bank1...bank12
; Overcomes 151 error problems by declaring shadow variables
; dim array,10 for example will produce assembler constants array0a,array1a,..,array9a
; It also produces an assembler constant array0v
    variable    point =0
    variable    bankc   =-1
dim macro x,n
    radix   dec
    errorlevel -207
    if  n> 0x50
        error max array size decimal 80 you will need to use indirect addressing in flat mode
    endif
    variable    i=0
    if point == 0
        variable    point = 0x70
        udata_shr
    endif
    if ((point+n-1) <0x80) & (bankc==-1)
        x   res #v(n)
        while i<n
            x#v(i)a equ point+i
            i++
        endw
    point= point+i
    messg x located in shared memory from memory location: decimal #v(point-n) to #v(point-1)

    else
        tempv=(point+n)-0x80*(point/0x80)
   ;     messg   point value #v(point) : n value #v(n) :  tempv value #v(tempv)
        if tempv >0x70
            bankc = bankc+1
            sect#v(bankc) udata  0x20+0x80*bankc
            point = 0x20+0x80*bankc
            i=0
        endif
        x   res #v(n)
        while i<n
            x#v(i)a equ point+i
            i++
        endw
        point= point+i
        messg x located in bank#v(bankc) from memory location: decimal #v(point-n) to #v(point-1)
    endif
    x#v(0)s equ n   ;Assembler Constant with size of array
    errorlevel +207
 endm
SeanD
 
Posts: 3
Joined: Mon Jun 02, 2014 5:53 pm
PIC experience: Professional 5+ years with MCHP products

Return to 14-Bit Core (enhanced)

Who is online

Users browsing this forum: No registered users and 2 guests

cron