Re: How is memory managed with micro controllers using assem
Hi,
Well can see where you are coming from with your questions and there are several ways to answer your points - however that could lead to a long discussion.
As to a tutorial on Memory usage, the Microchip site has masses of info on it, however finding it is like a treasure hunt, only today a friend mailed me some Microchip Video tutorials for Mplab Simulator he had easily found on a non microchip site !
Think again a simple example will speak volumes, though here I am refering to the pic18F chips whos memory is organised so much better than the more popularly covered 16F chips.
Again look at a datasheet, say the pic18F4520 or the 16F628 and locate the DATA Memory Map.
This shows how it is divided in to two distinct areas, the SYSTEM registers and the USER Registers and the locations /addresses the occupy.
On the 4520 you would first indicate what Label / Names you want to assign to your User registers
cblock 0x00 ; start user ram at location h 0x00
counter1 ; label counter1 is assigned to memory location 0x00
counter2 ; to 0x01 etc etc
counter3
temp1
temp2
temp3
endc ; end of data
In your main program code you then simply refer to that ram location by the Label and the system takes care of everything for you.
Movlw 0x45
movwf counter1 ; load data 0x45 into counter 1
incf counter1
decf counter1
When you need to address large arrays of data then the use of labels become impractical so you can then use the FSR as mentioned before to read and write to the locations you specify.
There are loads of assembler tutorials around, have a look at some and use one that seems good to you - using MPLAB and its Simulator you can follow each instruction step by step and see how the system is dealing with the data.
Have a look at
ttp://www.youtube.com/watch?v=pnkUOL0mmyA&feature=related