Page 1 of 1

Flowcode, pointers, tables, c code and assembler

Posted: Wed Jan 04, 2012 11:37 am
by r_romeo
Hi
I am working on a project were I get data from an input (rs-232, CAN, etc) , depending on the data , can be classified in two types , so I have two tables were they can be placed

I need to compare each variable with all the ones that are in the opposite table

I am not expert in C, but I find a routine in assembler that can work for my purposes

My problem is both tables need a starting address but I am afraid of overwriting the ones used by the C code , and also the C code can overwrite later
I there a way of writing in assembler a generic space for both tables?

here is the code I think can help me

movlw 0x60
movwf tabla1 ; assign first address for table1
movlw 0x70
movwf tabla2 ;assign first address for table2

in_comp movf tabla1,W
movwf FSR ; pointer to the first address of table1

movf INDF,w ;data in the first address of table1-->w
movwf temp1 ;w-->temp1 (we need w y FSR)

movf tabla2,W
movwf FSR ;pointer to the first address of table2

movf INDF,w ;data in the first address of table2-->w

subwf temp1,F ;w-temp1-->temp1
btfss STATUS,Z ;¿is zero?
goto different ;NO
goto equal ;SI

different bsf F_COMP_RX; flag tells has found a non coincident byte

return

equal bcf F_COMP_RX ; is 'z', last byte
sublw 'z' ; checks if the data is the last one (z)


btfss STATUS,Z ;¿is the lats one?
goto comp_nofin ; is not 'z'
return

comp_nofin incf tabla1; go to the next address of table1
incf tabla2; go to the next address of table2
goto in_comp ;keeps on comparing


can someone guide me through the process of implementing this code? will this work? is there any other way of doing it? without c or assembler?

Re: Flowcode, pointers, tables, c code and assembler

Posted: Wed Jan 04, 2012 11:51 am
by Benj
Hello,

This should be possible using Flowcode arrays or if pushed C code. This would be much simpler then assembler coding.

Flowcode arrays would have to be created and populated with the correct data at the top of your main.

A C code array can be coded to have initial values so you do not have to manually load the values in on start up.

You would then just need a loop in your Flowcode program to cycle through each element of the array and perform a comparison.