Searching \ for 'Programming question' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/devprogs.htm?key=programming
Search entire site for: 'Programming question'.

Truncated match.
PICList Thread
'programming question'
1997\03\02@145758 by Nishant Deshpande

flavicon
picon face
hi all,

i've just started programming the pic - i've got the led's lit up
etc etc now moving on to bigger & better things..

a couple of questions regarding common practice :

-       i started off assigning my own registers just using
       CTR     EQU     20h
       (for example)
       what i meant was i wanted to use address 20h
       now is it usual to use the 'DS' command to do this
       kind of thing? i.e.
               ORG     20h
       CTR     DS      1
               ORG     21h
       CTR2    DS      1

       i'm kinda unsure about the direct/indirect addressing..

-       say i want a small buffer (i.e. maybe 12/16 bits) - i do this
               ORG     30h
       BUFFER  DS      16

       now how do i get at this buffer? i know i can do BUFFER+<offset>
       but i want to use 'a variable' for the offset, increment it,
       etc etc as i would in a high level language...

       i thought of having another memory location holding a 'pointer'
       to my buffer and then incrementing/decrementing this - but
       trying to implement this seems kinda unnecessarily complex..

any tips? i guess i'm still thinking high level language...

thanks

nishant
ISE III BEng
Incremental Sanity Erosion at Imperial College

1997\03\02@152821 by Dennis Frost

flavicon
face
Hi Nishant

There is a register called the FSR (I think that stands for File Select
Register). You load the address of the start of the buffer into this
register. Then you read register 0 (I think it is called INDF) this
register will now hold the value of the register pointed to by the FSR.

Thus you would do something like this:

movlw   Buffer          ;this places the address of you 'Buffer' into w
movwf   FSR             ;place the address into FSR

Now you can work with the buffer:

movfw   INDF            ;This will put the value at Buffer into w

incf    FSR             ;Point to buffer+1

clrf    INDF            ;clear the data at Buffer+1

You can increment, decrement, add to & subtract from the FSR like with any
other register

I often use this method when I have a piece of code that performs a similar
function of a lot of registers.

Here is an example of how I define my variables:

       CBLOCK  0ch
       SaveW           ;01 holds W register durring interrupt
       SaveS           ;02 holds Status register durring interrupt
       SaveFSR         ;03 Holds copy of FSR durring interrupt
       T1              ;04 Timer values
       T2              ;05
       T3              ;06
       T4              ;07
       ENDC

I like using this method because if I want to add a variable say between
SaveS and SaveFSR (it makes more visual sense for whatever reason) the I
don't have to renumber all the variables. The compiler will renumber
consecutively them from 0ch until it reaches ENDC.

As for setting up the buffer, I have not had to do that so I couldn't tell
you for sure but I think you are right.

Cheers
       Dennis
____________________________________________________
FROST - Electronic Design, Manufacture & Consulting.
Dennis Frost
Tel:   +27 331 965125
Cel:   +83 2275216
Email: spam_OUTdennis.frostTakeThisOuTspampixie.co.za
Pietermaritzburg, South Africa
Products:       Medical Motivational equipment
               Timers for food processing
               Random number generator
               Temperature controllers
____________________________________________________

PS Anyone looking for someone in the hardware/software development fields,
I am available. I intend leaving South Africa for the West coast of the US
early this year.
----------

{Quote hidden}

1997\03\02@153458 by Mike

flavicon
face
>I often use this method when I have a piece of code that performs a similar
>function of a lot of registers.
>
>Here is an example of how I define my variables:
>
>        CBLOCK  0ch
>        SaveW           ;01 holds W register durring interrupt
>        SaveS           ;02 holds Status register durring interrupt
>        SaveFSR         ;03 Holds copy of FSR durring interrupt
>        T1              ;04 Timer values
>        T2              ;05
>        T3              ;06
>        T4              ;07
>        ENDC

Could this be analogous to setting up an object oriented procedure  ?

Rgds

Mike

Some say there is no magic but, all things begin with thought then it becomes
academic, then some poor slob works out a practical way to implement all that
theory, this is called Engineering - for most people another form of magic.
                                                                      Massen

1997\03\02@154700 by Nishant Deshpande

flavicon
picon face
ok gotcha - i'm writing my buffer now - thanks dennis

nish
----

Dennis Frost wrote:
{Quote hidden}

1997\03\03@071428 by Andy Kunz

flavicon
face
At 07:57 PM 3/2/97 +0000, you wrote:
>                ORG     20h
>        CTR     DS      1
>                ORG     21h
>        CTR2    DS      1

Nishant,

You don't need to put all those ORGs there, as the assembler tracks what
you've used.

Simply do this:

       org     20h
CTR     ds      1
CTR2    ds      1

Then you can insert CTR1 between them:

       org     20h
CTR     ds      1
CTR1    ds      3
CTR2    ds      1

and it will know that CTR1 is 3 bytes long, moving CTR2 down.

To access the three bytes of CTR1, you can do the following

       bcf     C
       rlf     CTR1,F
       rlf     CTR1+1,F
       rlf     CTR1+2,F

Which is the same as multiplying CTR1 = CTR1 * 2.

To access it using FSR is correct, as detailed in another reply.

Andy
==================================================================
Andy Kunz - Montana Design - 409 S 6th St - Phillipsburg, NJ 08865
         Hardware & Software for Industry & R/C Hobbies
       "Go fast, turn right, and keep the wet side down!"
==================================================================

1997\03\03@142007 by Nishant Deshpande

flavicon
picon face
thanks Andy - this is getting to be fun!

cheers

nishant
----

Andy Kunz wrote:
{Quote hidden}


'Programming question'
2003\06\11@193008 by Sid Weaver
picon face
Could someone please tell me what this means:

Warn: EDBPIC.ASM 1015:(102) code crosses boundary at 800h
Warn: EDBPIC.ASM 1997:(102) code crosses boundary at 1000h
Warn: EDBPIC.ASM 2881:(102) code crosses boundary at 1800h

Thanks

Sid

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\06\12@085320 by Micro Eng

picon face
page boundaries?

Look at the .lst file....it will show you that you passed the boundary and
need to set the page bits


{Quote hidden}

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail

--
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

2003\06\12@085323 by Byron A Jeff

face picon face
On Wed, Jun 11, 2003 at 07:25:53PM -0400, Sid Weaver wrote:
> Could someone please tell me what this means:
>
> Warn: EDBPIC.ASM 1015:(102) code crosses boundary at 800h
> Warn: EDBPIC.ASM 1997:(102) code crosses boundary at 1000h
> Warn: EDBPIC.ASM 2881:(102) code crosses boundary at 1800h

Just information for you. These are page boundaries and therefore could be
potentially affected by the value in the PCLATH register.

BAJ

--
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

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