Let's Make Robots!

Assembly PIC problems


For a collage project, I have to do some PIC programming in Assembly. I've made a start, but I'm having trouble defining some variables. Out of the 11 variables I'm using, it is only naming the middle 5 when I simulate it. They're all pretty much identical appart from the name and the position in the memory. Does anyone have any suggestions as to why this is happening?

Sorry for the lack of info. my code's at collage, and I'm not sure of the software (I think it's VPIC, or something similar).

Thanks in advance

FX3B.asm3.97 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Thanks for the help. I've got it working for now. The problem was I hadn't given some of the variables any value.

Thanks for the replies. I think I've manually assigned the memory, but i'm not sure. I've been using a template provided by the exam board, and it had a couple of example variables in already, so I just continued in a similar fashion. Sorry for the lack of code, but I've posted it now.

I don't use PICs, you didn't tell us which one you are using, we can't see your code, we don't know what assembler or simulator you are using, but nevertheless I will take a shot in the dark.  Just 'cause...  Are the "variables" all declared to be in the same bank of memory?  The one that is active?  Some PICs have banked memory to get around the small RAM address space.  If you declare variables in different banks, they won't be visible to the processor and hence the simulator unless the bank they are in is active.

For someone who doesn't use pics that's a pretty good stab bdk6. It's always best to use the universal ram first that is the 16 bytes that is accessable from any bank.
Declare your variables with:

INT_VAR     udata_shr //    INT_VAR is just a label and udata_shr is the directive

Variable1    RES 1  //    RES keyword reserves one byte of ram for this variable
Variable2    RES 1
Variable3    RES 1

From the mpasm users guide:

This directive is used to declare variables that are allocated in RAM that is shared across all
RAM banks (i.e. unbanked RAM).

I might point out that this is the case for relocatable code and object files.

If you are writing non-relocatable code then you can assign each variable manually to unbanked ram.
Like this.

Variable1    EQU 0x70  // 0x70 is a ram location in shared memory. The range of locations will vary between pics.
Variable2    EQU 0x71
Variable3    EQU 0x72

Variable16  EQU 0x7F

Look at the memory map in the datasheet to find where shared memory starts.

Well, I don't use PICs, but I am somewhat familiar with them.  That's why I don't use them! ;-)  It will be interesting to see if we are right.

Edit:  As a (hopefully) interesting note, the 8 bit PIC architecture dates to about 1975 and has remained almost unchanged.  It's history of mild success with General Instruments to it nearly ruling the 8 bit market with Microchip is pretty interesting.  I think Wikipedia has a nice article about it if anyone is interested.