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

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Wouldn't it be nice...'
2005\01\11@160258 by Bob Ammerman

picon face
Here is the start of a little thread of things we (or at least I) wish
microChip had thought of:

Microchip recently extended the 18F instruction set by providing support for
accessing values at offsets from FSR2. This allows a C compiler to generate
nice efficient code to access local variables.

Unfortunately, no similar functionality was implemented in the dsPIC30F. The
canonical way to access stack or local variables would seem to be (note: I
have not looked at the compiler output) something like:

   mov    #offset_value,Wa
   add    [W15+Wa],Wb

Wouldn't it be nice if you could write:

   add    [W15+#offset_value],Wa

instead.

This is not only good for accessing stack based variables, but also for
accessing elements of a structure which is pointed to by a W register.

I got to thinking about the various addressing methods provided on the
dsPIC30, and how mChip could have created a [base+offset] addressing mode.
Here is what I came up with:

Every instruction that supports "file" addressing to access the first 8K of
'NEAR' data memory (SFRs and RAM) has a 13-bit field to contain the file
address. By giving up the last 2K of 'NEAR' accessibility, you could store
values iin the 13-bit field of the following format:

11 bb nnnn ooooo

Where '11' is an indication that this instruction should use base+offset
addressing rather than 'file' addressing.

'bb' identifies the base register from the set {W0,W1,W14,W15}

'nnnn' identifies the register to be used in place of 'WREG' (W0) in the
execution of the instruction.

'ooooo' is a 5 bit signed literal value.

The effective address of the instruction then becomes:

The contents of the base register + twice the signed literal offset value.
This will permit access to values up to 16 words before and 15 words after
the word the base register is pointed at.

Note that some of the file register addressing instructions make no use of
the WREG. Examples are CLR F and RL F. In these instructions the value of
'nnnn' could always be zero, so you would be able to free up 15*32 = 480
instruction word code values for each such instruction.

Wouldn't it be nice....


Bob Ammerman
RAm Systems






2005\01\12@043929 by Michael Rigby-Jones

picon face


>-----Original Message-----
>From: spam_OUTpiclist-bouncesTakeThisOuTspammit.edu [.....piclist-bouncesKILLspamspam@spam@mit.edu]
>Sent: 11 January 2005 21:03
>To: Microcontroller discussion list - Public.
>Subject: [PIC]: Wouldn't it be nice...
>
>
>Here is the start of a little thread of things we (or at least I) wish
>microChip had thought of:
>
>Microchip recently extended the 18F instruction set by
>providing support for
>accessing values at offsets from FSR2. This allows a C
>compiler to generate
>nice efficient code to access local variables.

And unfortunately they managed to break things quite badly when adding
these extra instructions. The fast context save/restore is broken for
high priority interrupts on many (if not all) of the devices that
support these extra instructions.

Regards

Mike

=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================

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