MaxHeadRoom
- Joined Jul 18, 2013
- 28,697
Yes yours was the one I referred to!Personally, I meant it as self-deprecating,
Thanks Users!
On with the show.
Max.
Yes yours was the one I referred to!Personally, I meant it as self-deprecating,
Thanks Users!
One of the reasons I spent the time I did on this was to further hone my chops on MPLABX/MPASMX and the enhanced midrange stuff. I encountered the same problem you have i.e. no stinkin' variables in the watch window. I've been looking through the help files but nothing yet. There are fleeting references to 'fast stepping' in the debugger and I've occasionally seen the *multiple* instances of IO_ModeBase that I've typed in but they go away as soon as I step.I usually would do this in the Watch window and simply add my variable names to the list. This doesn't seem to work when using the simulator. All I've been able to do is look at the PIC pins, but nothing internal to the pseudo-PIC.
Can this be done with the simulator or is this only for the device level debugging?
In this case, hovering over the variable shows it as 'Not Recognized'I can hover over a variable in the source, and then I see the current value. Simple. The disassembly view is now shown for the function which is executed currently (place a breakpoint there).
This is making MPASM do some of the work of keeping track of offset sizes etc. The '$' means current program counter so $-_IOmode0 is the the number of goto's between those two statements and in turn, calculates the size, in PC counts, of the goto array that make up 1 mode. This size (8) is important since the code needs the offset of the first goto for each mode. That's why the simulated BCD switch gets multiplied by the size of one mode (8). It works just to use '8' directly but consider what happens when you want to expand the table - maybe more IO or an separate entries for set and reset an output. The table will grow and you'll to recalculate the new size of one mode's goto list and then make sure that everything that uses it is also updated. Failure to do this will ensure pandemonium and since its a jump table, can present some very challenging debugging as the program can sail off into space at seemingly random times. Not recommended.You use variable(?) _sizeofIOmode (in the READ BCD subroutine). I see it defined later as " equ $ - _IOmode0). I thought equ were to specify an actual number. What does the "$" signify in this case. I've used it for use in my goto's - is it the program counter? How does the _IOMode0 figure into the equation? Isn't this the name of the subroutine?
correct. Is only evaluted at compile/assembly time.Darnn, where were you when I needed you?
Scratch that, I STILL need you.
I did something similar already when I created a table to read data from.
My first table entry was a data point telling the program how much data was in the table to be read out. I didn't know there was a better way to determine the size.
Which, of course, leads me to another question.
How does the PIC make that determination?
I thought the PIC would individually step through the program and perform tasks as it approached them and that the program counter would tell it where the next instruction is.
Seems to me, that when it comes to the "sizeofIOmode"; it doesn't know what that is, does it? Does it then search out the equation for "sizeofIOmode" and then calculate it?
When performing this type of calculation, what if the parameters used for the calculation have changed? Does it use the collected data when the statement calculation is needed?
Or does it make the determination once for the entire program and never change it?
Seems to me like the equ statement gets executed only once per program build and is not changeable, right?
You may be confusing what happens at build-time vs. run-time. Simply put, the PIC is only active at run-time and it just executes a sequence of bits and bytes. It knows nothing of labels, equs or any fancy sizeof stuff. It merely reads the bits from the memory location addressed by the PC, executes the instruction they represent, bumps the PC and repeats. Gotos etc modify this sequence by jamming a new value into the PC then off it goes reading memory from the new address. If you look at the detailed instruction list, the bit patterns for each are shown. Imagine having to manually create and stuff those patterns into memory to program the PIC.I did something similar already when I created a table to read data from.
My first table entry was a data point telling the program how much data was in the table to be read out. I didn't know there was a better way to determine the size.
Which, of course, leads me to another question.
How does the PIC make that determination?
I thought the PIC would individually step through the program and perform tasks as it approached them and that the program counter would tell it where the next instruction is.
Seems to me, that when it comes to the "sizeofIOmode"; it doesn't know what that is, does it? Does it then search out the equation for "sizeofIOmode" and then calculate it?
!void refresh_line(unsigned char v_phase)
0x2C5: BCF STATUS, 0x5
0x2C6: BCF STATUS, 0x6
0x2C7: MOVWF v_phase
!{unsigned char i,anode;
! unsigned char* portio;
!
! for(i=0;i<c_phases;i++)
0x2C8: CLRF i
0x2C9: MOVLW 0x5
0x2CA: SUBWF i, W
0x2CB: BTFSC STATUS, 0x0
0x2CC: GOTO 0x316
0x30E: MOVLW 0x1
0x30F: MOVWF c
0x310: MOVF c, W
0x311: ADDWF i, F
0x312: MOVLW 0x5
0x313: SUBWF i, W
0x314: BTFSS STATUS, 0x0
0x315: GOTO 0x2CD
! {
! anode=anodes;
0x2CD: MOVF i, W
0x2CE: ADDLW 0x9E
0x2CF: MOVWF FSR
0x2D0: MOVLW 0x81
0x2D1: BTFSC STATUS, 0x0
0x2D2: ADDLW 0x1
0x2D3: MOVWF 0x7F
0x2D4: BCF PCLATH, 0x3
0x2D5: CALL 0x100
0x2D6: BCF PCLATH, 0x3
0x2D7: MOVWF c
0x2D8: MOVF c, W
0x2D9: MOVWF anode
! portio=pin_port1[anode];
0x2DA: MOVF anode, W
0x2DB: MOVWF c
0x2DC: ADDWF c, W
0x2DD: ADDLW 0x20
0x2DE: MOVWF FSR
0x2DF: BCF STATUS, 0x7
0x2E0: MOVF INDF, W
0x2E1: MOVWF portio
0x2E2: INCF FSR, F
0x2E3: MOVF INDF, W
0x2E4: MOVWF font_data_size
! if(i==v_phase)*portio|=pin_bit_set1[anode];
0x2E5: MOVF i, W
0x2E6: XORWF v_phase, W
0x2E7: BTFSS STATUS, 0x2
0x2E8: GOTO 0x2FC
0x2E9: MOVF anode, W
0x2EA: ADDLW 0x7A
0x2EB: MOVWF FSR
0x2EC: MOVLW 0x81
0x2ED: BTFSC STATUS, 0x0
0x2EE: ADDLW 0x1
0x2EF: MOVWF 0x7F
0x2F0: BCF PCLATH, 0x3
0x2F1: CALL 0x100
0x2F2: BCF PCLATH, 0x3
0x2F3: MOVWF c
0x2F4: MOVF portio, W
0x2F5: MOVWF FSR
0x2F6: BSF STATUS, 0x7
0x2F7: BTFSS font_data_size, 0x0
0x2F8: BCF STATUS, 0x7
0x2F9: MOVF c, W
0x2FA: IORWF INDF, F
0x2FB: GOTO 0x30E
! else *portio&=pin_bit_reset1[anode];
0x2FC: MOVF anode, W
0x2FD: ADDLW 0x62
0x2FE: MOVWF FSR
0x2FF: MOVLW 0x81
0x300: BTFSC STATUS, 0x0
0x301: ADDLW 0x1
0x302: MOVWF 0x7F
0x303: BCF PCLATH, 0x3
0x304: CALL 0x100
0x305: BCF PCLATH, 0x3
0x306: MOVWF c
0x307: MOVF portio, W
0x308: MOVWF FSR
0x309: BSF STATUS, 0x7
0x30A: BTFSS font_data_size, 0x0
0x30B: BCF STATUS, 0x7
0x30C: MOVF c, W
0x30D: ANDWF INDF, F
! }
!
! for(i=0;i<(display_width/2);i++)
0x316: CLRF i
0x317: MOVLW 0x7
0x318: SUBWF i, W
0x319: BTFSC STATUS, 0x0
0x31A: RETURN
0x31B: MOVLW 0x1
0x31C: MOVWF c
0x31D: MOVF c, W
0x31E: ADDWF i, F
0x31F: GOTO 0x317
void refresh_line(unsigned char v_phase)
{unsigned char i,anode;
unsigned char* portio;
for(i=0;i<c_phases;i++)
{
anode=anodes;
portio=pin_port1[anode];
if(i==v_phase)*portio|=pin_bit_set1[anode];
else *portio&=pin_bit_reset1[anode];
}
for(i=0;i<(display_width/2);i++)
{
}
}
What makes you think my C isn't amazing as well?Sure if you use the maximum of your mental powers, you can do amazing things in assembler.
I mean, you use the maximum of your mental powers, and your assembler code is quite sophisticated, and the program does something cool.
But think what you could do in C if you use the maximum of your mental powers.
I did not say that. However, I have during long nights taken a look at a lot of assembler sources which can be found on the internet. Both professional stuff (including some mysterious Bill Gates sources), and homegrown stuff. One homegrown source was about 1 Megabyte.What makes you think my C isn't amazing as well?
by Jake Hertz
by Jake Hertz
by Duane Benson
by Duane Benson