Author Topic: Creation of a variable in ASM file for PIC 12F675  (Read 6545 times)

0 Members and 1 Guest are viewing this topic.

Offline EENGTopic starter

  • Contributor
  • Posts: 21
Creation of a variable in ASM file for PIC 12F675
« on: January 22, 2012, 11:48:48 am »
Hallo

I am busy getting familiar with the whole ASM  SW for programming the pic PIC 12F675 in my PIC KIT 1 demo board. I am a first time programmer.

In one of the demo files they create two variables as shown below (question follows afterwards):


;************************** VARIABLE DEFINITIONS ******************************

      cblock   0x20         
   STATE_LED         ; LED state machine counter
   STATE_DEBOUNCE         ; button debounce state machine counter
      endc

;***************************************************************************


Question:
1. What does cblock 0x20 exactly do?

2. How does one ascertain how big the variable is? In notherwords, when I create a variable, is it 8bits wide? Or 16 bits wide?

3. Suppose I wanted to create a variable that was 32bits wide, how does one do this?
 

alm

  • Guest
Re: Creation of a variable in ASM file for PIC 12F675
« Reply #1 on: January 22, 2012, 12:19:21 pm »
cblock/endc allocates the following variables at the address 0x20, see MPASM help or any decent tutorial. All registers, and hence assembly variables, are 8 bit wide on 8-bit PICs. Longer variables will have to be split across several registers, and for arithmetic you'll have to do something like this.

Higher level programming languages like C will do this automatically.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Creation of a variable in ASM file for PIC 12F675
« Reply #2 on: January 22, 2012, 09:16:16 pm »
You'll want to look at http://ww1.microchip.com/downloads/en/DeviceDoc/33014K.pdf
The manual for the assembler.  This is often neglected in between the device datasheets and architecture descriptions and "make it work" tutorials, but you need it to explain the details of the tools.
 

Offline Bambur

  • Regular Contributor
  • *
  • Posts: 70
Re: Creation of a variable in ASM file for PIC 12F675
« Reply #3 on: January 26, 2012, 02:00:01 pm »
Here are answers to your questions 2 and 3.

cblock START_ADDRESS

Var1:1 ; 8-bit wide variable
Var2:2 ; 16-bit
Var3:4 ; 32-bit

endc

PIC Assembler is very easy!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf