Searching \ for '[PIC]: Mapping Variables' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Mapping Variables'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Mapping Variables'
2001\01\11@202138 by JB

flavicon
face
Is there a function of MPLAB, or some third-party tool for mapping out which subroutines use what variables? Another thing I'd like to see is a chart of what sub calls which other subs. Have not found either as of yet.

JB

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2001\01\13@213603 by Scott Dattalo

face
flavicon
face
(cc'd to gnupic)

On Thu, 11 Jan 2001, JB wrote:

> Is there a function of MPLAB, or some third-party tool for mapping out which
> subroutines use what variables? Another thing I'd like to see is a chart of
> what sub calls which other subs. Have not found either as of yet.

I'm somewhat reluctant to mention it since it's total vaporware, but as part of
the PIC port to SDCC (http://www.dattalo.com/gnupic/sdcc.html) I'll be working
on a "post compiler optimizer". It's purpose is to take the assembly output of
the SDCC compiler and optimize it. One of the steps will be to generate the call
tree. The variable "mapping" as you call it, will also be available.

The optimizer will initially be buried in SDCC. However, I intend to design it
such that it will also work on a .asm file. In this case, I'll modify gpasm to
generate the same information that I'm getting from SDCC. gpasm will provide the
syntax checking, macro expansion, etc. So in addition to producing .cod, .hex,
and .lst files, gpasm will produce a .opt (or whatever) file that is an
optimized .asm file.

Scott

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\14@205207 by JB

flavicon
face
Thanks Scott. In the absence of replies and an unsuccessful search, I decided to throw together a VB program to produce an analysis. It is by no means perfect, but has helped me to recover some variable memory, which is all that counts in the end. FYI, the output I generated looks something like that shown below for each subroutine, with a unique list of variables modified and calls made.

[tcp_do_ack:]
*pktdata+eth_len_h*
*pktdata+eth_len_l*
*pktdata+ip_len+0*
*pktdata+ip_len+1*
*pktdata+tcp_hlen*
*pktdata+tcp_wins+0*
*pktdata+tcp_wins+1*
       >do_ip_checksum:
        *FSR*
        *pktdata+ip_cksum*
        *pktdata+ip_cksum+1*
               >oc_getsum:
                *tmp_a*
                *tmp_b*
               >oc_startsum:
                *tmp_a*
                *tmp_b*
                *tmp_c*
       >reply_set_ip:
        *pktdata+ip_dst*
        *pktdata+ip_dst+1*
        *pktdata+ip_dst+2*
        *pktdata+ip_dst+3*
        *pktdata+ip_src*
        *pktdata+ip_src+1*
        *pktdata+ip_src+2*
        *pktdata+ip_src+3*
       >reply_set_mac:
        *pktdata+eth_dest_0*
        *pktdata+eth_dest_1*
        *pktdata+eth_dest_2*
        *pktdata+eth_dest_3*
        *pktdata+eth_dest_4*
        *pktdata+eth_dest_5*
        *pktdata+eth_src_0*
        *pktdata+eth_src_1*
        *pktdata+eth_src_2*
        *pktdata+eth_src_3*
        *pktdata+eth_src_4*
        *pktdata+eth_src_5*
       >reply_set_tcp_port:
        *pktdata+tcp_dst*
        *pktdata+tcp_dst+1*
        *pktdata+tcp_src*
        *pktdata+tcp_src+1*
        *tmp_e*
       >send_pkt:
        *a0*
        *a1*
        *a2*
        *a3*
        *FSR*
        *tmp_b*
        *tmp_c*
               >OutByte:
                *iow*
                *PORTB*
                *tmp_a*
       >tcp_ack_add_w:
        *pktdata+tcp_ack+0*
        *pktdata+tcp_ack+1*
        *pktdata+tcp_ack+2*
        *pktdata+tcp_ack+3*
       >tcp_calc_data_len:
        *pktdata+ip_len+1*
        *pktdata+tcp_hlen*
        *tmp_e*
       >tcp_do_cksum:
        *FSR*
        *pktdata+ip_len+1*
        *pktdata+tcp_cksum*
        *pktdata+tcp_cksum+0*
        *pktdata+tcp_cksum+1*
        *tmp_a*
        *tmp_b*
        *tmp_c*
        *tmp_e*
               >oc_cumsum:
                *FSR*
                *STATUS*
                *tmp_a*
                *tmp_b*
                *tmp_c*
                *tmp_d*
               >oc_getsum:
                *tmp_a*
                *tmp_b*
               >oc_startsum:
                *tmp_a*
                *tmp_b*
                *tmp_c*
       >tcp_seq_to_ack:
        *pktdata+tcp_ack+0*
        *pktdata+tcp_ack+1*
        *pktdata+tcp_ack+2*
        *pktdata+tcp_ack+3*
        *pktdata+tcp_seq+0*
        *pktdata+tcp_seq+1*
        *pktdata+tcp_seq+2*
        *pktdata+tcp_seq+3*
        *tmp_e*
[/tcp_do_ack:]

I'd be happy to release the VB5 source if it would be helpful to anyone - send me a private e-mail with your request.

JB

At 07:09 PM 1/13/01 -0600, you wrote:
{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\14@214453 by Tony Nixon

flavicon
picon face
How do you decide the end of a subroutine?

Test    movf Value,W
       xorwf Tval,W
       btfsc STATUS,Z
       retlw 'Y'

       movf Value2,W
       btfsc STATUS,Z
       retlw 'N'
       retlw '?'

Surely there would need to be markers added to the code.

; [SubStart - Test]

Test    movf Value,W
       xorwf Tval,W
       btfsc STATUS,Z
       retlw 'Y'

       movf Value2,W
       btfsc STATUS,Z
       retlw 'N'
       retlw '?'

; [SubEnd - Test]

Probably be a nightmare with 'spagetti code' - which can be bad
practice, but is sometimes unnavoidable.

Test    movf Value,W
       xorwf Tval,W
       btfsc STATUS,Z
       retlw 'Y'

       movf Value2,W
       btfsc STATUS,Z
       retlw '?'

       movlw High(Test2)
       movwf PCLATH
       goto Test2

--
Best regards

Tony

mICro's
http://www.picnpoke.com
.....salesKILLspamspam@spam@picnpoke.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\14@222509 by Scott Dattalo

face
flavicon
face
On Mon, 15 Jan 2001, Tony Nixon wrote:

> How do you decide the end of a subroutine?
>
> Test    movf Value,W
>         xorwf Tval,W
>         btfsc STATUS,Z
>         retlw 'Y'
>
>         movf Value2,W
>         btfsc STATUS,Z
>         retlw 'N'
>         retlw '?'

if this were written in C:

char Test(void)
{
 if(Value == Tval)
   return 'Y';

 if(Value2)
   return 'N';

 return '?';

}

It's clear from this where the end of the function is. But you're right, the
demarcation of functions is going to be difficult to ascertain algorithmically.


{Quote hidden}

This is one solution that works really well. In fact, in the SDCC PIC port I
have just that sort of information availailable.

One way to determine where a function begins is to follow this simple algorithm:

1) Find the destination of every call and arbitrarily say that this is the entry
of a function.
2) Examine the instruction preceeding the entry point. If it is not a return,
then the entry point is NOT the start of a function. If it is a return, then it
will be the start of the function if instruction preceeding the return is not a
btfss/btfsc.

  ....
   clrf  x
   return
f1:                ; start of a function
   clrf  Tval
f2:                ; not the start of a function
   movf  Value,W
   xorwf Tval,W
   skpnz
    retlw 'Y'

f3:                ; not the start of a function
   movf  Value2,w
   skpnz
    retlw 'N'
   retlw  '?'

Even though f2 and f3 are not the start of functions, they may still be called
from some other address in the PIC. That's the beauty of assembly
language; anything goes!

{Quote hidden}

This is a more complicated case. This kind of code is what can get generated by
a C-compiler's tail merging algorithm (right James?). In this case, the compiler
discovers two functions that end identically. Rather than duplicating the code,
the compiler decides to generate only one copy. One of the functions jumps to
the common ending of the other.

I'm sure if we think about for a few minutes, we'll find boundary conditions
that defy categorization. (My software PWM routine come sto mind). However, it's
still possible to determine a majority the cases.

Scott

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\14@224545 by James Newton

face picon face
I would love to provide you with web space at http://www.piclist.com to publish
your program. If it could be translated to VB Script (subset of VB) I would
make it available on the site as an active server page so that people with
other operating systems (besides Windows) could use it directly from the
site.

In any case, please send a copy to me personally.

James Newton, PICList Admin #3
jamesnewtonspamKILLspampiclist.com
1-619-652-0593 phone
http://www.piclist.com

{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...