Hey Guys
I'm having a bit of confusion with a some code directive
I presume u know them better than me.
I would refer to a code to base my question.
example code, taken from a counter programe which I am trying to figure out how it works, PIC is 16F88
pls note his counter is tested by me practically, and taken from a pic project site, since the author has told no to emails, I have to ask somewhere else.
I'll base my questions from top.
I understand the org 0x00, which means the reset vector, or the way I understand it, it is where the PC starts. Am I right.
But in this code it states
Q1: ORG 0x2100 ; why does it states 0x2100, I mean if "2100" is in HEX, then I cannot find that value in the F88 register map, maximum value is 1FFh, so how the heck 2100 comes here.
Q2: "de 0xFF ; mode"
what is "de" and why "0xFF" ?
Q3: "ORG 0x2101
de 0,0,0,0 ; counter preset"
again why "0x2101" and what is "de 0,0,0,0" why this part is commented as counter preset?
Now I understand cblock 0x20, which is used assign 8 bit variables to sram or PGR's for context saving, but there is one thing I like to clarify.
Q4: The GPR starts at 20h from bank0 and ends at 7Fh, which is 96 bytes
Correct me if I am wrong. cblock 0x20 to 7Fh gives me a total of 96 8bit registers to save whatever data I want. By looking at the cblock in the above code it starts from "debounce" and ends to "state". which assigns 19 8bit variables, Right?
Q5: So does this mean that I can assign 77 more variables and if I were to go above that I have to end the first cblock and start another "cblock at 0xA0h in bank1. below is an example of what I would write when assigning variables , say 100 variables.
Q5: Looking back to the code which states
; indicator LEDs
overflow equ 0
hold equ 1
up equ 2
down equ 3
; flag bits
invert equ 0
suppressZeros equ 1
resetNext equ 2
keysReady equ 3
intEdge equ 4
The counter has indicator leds which are multiplex with the segment drive PORTB, which are overflow, hold, up and down. now thw codes states that these are equal to 0 thru 3, now
one problem is whether "EQU" is same as "RES" directive, and
what does the 0 thru 3 states ( this numeric value is what I do not understand). I ask this because the code has the same value equate to invert, suppressZero, resetNext and keysReady.
Why the same value assigned to different things
Why is that, and how does the assembler know that some are indicators and other are flags bits without a label.
No tutorial or no one has ever explained these, and I have read all there is on the net and I am tired of searching
Q6: Last is the define directive
#define digitDrive PORTA
#define segmentDrive PORTB
#define overflowPulse PORTA,7
#define switchIn PORTA,6
#define countIn PORTB,0
Now I understand define up to some extent what confuses me are these.
#define digitDrive PORTA
this definition manipulates the PORTA when ever a digitDrive is used in the code. Now in this counter PORTA has inputs and outputs set. so if the codes tells to write to digitdrive won't it effect the overflowpulse at PORTA, 7, or is it that by defining PORTA,7 seperately, the digitdrive command excludes PORTA,7.
Same goes for PORTB, segmentdrive outputs and switchin and countin inputs.
If any one can clarify me these I would really appreciate it.
Thanks
Rifaa
I'm having a bit of confusion with a some code directive
I presume u know them better than me.
I would refer to a code to base my question.
example code, taken from a counter programe which I am trying to figure out how it works, PIC is 16F88
pls note his counter is tested by me practically, and taken from a pic project site, since the author has told no to emails, I have to ask somewhere else.
Rich (BB code):
org 0x2100
de 0xFF ; mode
org 0x2101
de 0,0,0,0 ; counter preset
org 0x2108
de "counter.asm"
errorlevel -302 ; suppress banksel warning messages
errorlevel -311 ; suppress HIGH operator warning messages
cblock 0x20
debounce
Unit
Tens
Hund
Thou
unit7seg
tens7seg
hund7seg
thou7seg
indLED
mplxrot
keyNow
keyLast
keyEdge
loadUnit
loadTens
loadHund
loadThou
state
endc
cblock 0x70
Wisr
Sisr
flags
endc
#define bank0 bcf STATUS,RP0 ; Sel Bank 0
#define bank1 bsf STATUS,RP0 ; Sel Bank 1
; indicator LEDs
overflow equ 0
hold equ 1
up equ 2
down equ 3
; flag bits
invert equ 0
suppressZeros equ 1
resetNext equ 2
keysReady equ 3
intEdge equ 4
#define digitDrive PORTA
#define segmentDrive PORTB
#define overflowPulse PORTA,7
#define switchIn PORTA,6
#define countIn PORTB,0
I understand the org 0x00, which means the reset vector, or the way I understand it, it is where the PC starts. Am I right.
But in this code it states
Q1: ORG 0x2100 ; why does it states 0x2100, I mean if "2100" is in HEX, then I cannot find that value in the F88 register map, maximum value is 1FFh, so how the heck 2100 comes here.
Q2: "de 0xFF ; mode"
what is "de" and why "0xFF" ?
Q3: "ORG 0x2101
de 0,0,0,0 ; counter preset"
again why "0x2101" and what is "de 0,0,0,0" why this part is commented as counter preset?
Now I understand cblock 0x20, which is used assign 8 bit variables to sram or PGR's for context saving, but there is one thing I like to clarify.
Q4: The GPR starts at 20h from bank0 and ends at 7Fh, which is 96 bytes
Correct me if I am wrong. cblock 0x20 to 7Fh gives me a total of 96 8bit registers to save whatever data I want. By looking at the cblock in the above code it starts from "debounce" and ends to "state". which assigns 19 8bit variables, Right?
Q5: So does this mean that I can assign 77 more variables and if I were to go above that I have to end the first cblock and start another "cblock at 0xA0h in bank1. below is an example of what I would write when assigning variables , say 100 variables.
Is this correct, ( or does it require banksel directive?; Variables
cblock 0x20
1st variable
x
go's
till
x
96th Variable
endc
cblock 0xA0h
97th variable
x
to
x
100th variable
endc
Q5: Looking back to the code which states
; indicator LEDs
overflow equ 0
hold equ 1
up equ 2
down equ 3
; flag bits
invert equ 0
suppressZeros equ 1
resetNext equ 2
keysReady equ 3
intEdge equ 4
The counter has indicator leds which are multiplex with the segment drive PORTB, which are overflow, hold, up and down. now thw codes states that these are equal to 0 thru 3, now
one problem is whether "EQU" is same as "RES" directive, and
what does the 0 thru 3 states ( this numeric value is what I do not understand). I ask this because the code has the same value equate to invert, suppressZero, resetNext and keysReady.
Why the same value assigned to different things
Why is that, and how does the assembler know that some are indicators and other are flags bits without a label.
No tutorial or no one has ever explained these, and I have read all there is on the net and I am tired of searching
Q6: Last is the define directive
#define digitDrive PORTA
#define segmentDrive PORTB
#define overflowPulse PORTA,7
#define switchIn PORTA,6
#define countIn PORTB,0
Now I understand define up to some extent what confuses me are these.
#define digitDrive PORTA
this definition manipulates the PORTA when ever a digitDrive is used in the code. Now in this counter PORTA has inputs and outputs set. so if the codes tells to write to digitdrive won't it effect the overflowpulse at PORTA, 7, or is it that by defining PORTA,7 seperately, the digitdrive command excludes PORTA,7.
Same goes for PORTB, segmentdrive outputs and switchin and countin inputs.
If any one can clarify me these I would really appreciate it.
Thanks
Rifaa