Reputation: 9
i have a problem converting assembly code for microchip pic into C language it is two parts first part is
movlw HIGH RevTable ; get MS byte of table
and the table is
RevTable
retlw B’00000000’ ; invalid
retlw B’00100001’ ; phase /6
retlw B’00000110’ ; phase /4
retlw B’00100100’ ; phase /5
retlw B’00011000’ ; phase /2
retlw B’00001001’ ; phase /1
retlw B’00010010’ ; phase /3
retlw B’00000000’ ; invalid
so what does that mean? i can not understand it
the second question is
incfsz ADC,w ; if ADC is 0xFF we’re at full speed - skip timer add
how it could be in the C thanks a lot
Upvotes: 0
Views: 1084
Reputation: 10937
Your code sample is insufficient so I can't tell you all about:
movlw HIGH RevTable ; get MS byte of table
This is only a part of computed table jump. Your asm code must look something like:
movlw HIGH RevTable
movwf PCLATH ;set high byte RevTable address
movf TableIndex, w
movwf PCL ;set low byte RevTable address this is computed table jump
;The return value is in wreg so one from RevTable table depend of TableIndex value
In c something like:
char RevTable[] = {'0','6','4','5','2','1','3','0'};
char TableIndex = 1;
char ValueFromTable;
ValueFromTable = RevTable[TableIndex] ;
The second part of code:
incfsz ADC,w ; if ADC is 0xFF we’re at full speed - skip timer add
Here is missing the second asm instruction which is executed or not depend of ADC value, something like:
if (ADC != 255) ...
Upvotes: 4