Kabak
Super Member
- Total Posts : 250
- Reward points : 0
- Joined: 2014/07/30 03:47:55
- Location: 0
- Status: offline
XC8 inline asm branch instruction BNOV
XC8 1.33 PIC18f26k22 XC8 does not recognize BNOV inline asssembler instruction with error: (876) syntax error uchar Temp3 = 0; uchar Temp = DecValue & 0xF0; uchar Temp2 = DecValue & 0x0F;
#asm MOVF ByteToHex@Temp2,0 ADDWF ByteToHex@Temp3,1 BNOV Jump // Here i got syntax error 876 GOTO End_ByteToHex Jump: MOVLW 6 ADDWF ByteToHex@Temp3,1
End_ByteToHex: #endasm If I change instruction to BNZ , for example for checking , there is no error Is it compiler bug ?
|
NorthGuy
Super Member
- Total Posts : 6518
- Reward points : 0
- Joined: 2014/02/23 14:23:23
- Location: Northern Canada
- Status: offline
Re: XC8 inline asm branch instruction BNOV
2021/01/23 16:08:47
(permalink)
Kabak Is it compiler bug ?
If everything is as you describe, then definitely so. Looks like you were the first who used BNOV in the inline assembler. I suggest reporting it to Microchip.
|
Mysil
Super Member
- Total Posts : 4114
- Reward points : 0
- Joined: 2012/07/01 04:19:50
- Location: Norway
- Status: offline
Re: XC8 inline asm branch instruction BNOV
2021/01/23 17:12:41
(permalink)
Hi, Reporting a possible bug in a compiler version that was released 7 years ago, may not get much attention within Microchip. You may have to try different compiler versions. Also check that there is no macro "#define ............... " anywhere in the project, that redefine the instruction, or otherwise confuse the compiler. Mysil
|
1and0
Access is Denied
- Total Posts : 12086
- Reward points : 0
- Joined: 2007/05/06 12:03:20
- Location: Harry's Gray Matter
- Status: offline
Re: XC8 inline asm branch instruction BNOV
2021/01/23 17:33:15
(permalink)
Kabak XC8 1.33 PIC18f26k22 XC8 does not recognize BNOV inline asssembler instruction with error: (876) syntax error #asm MOVF ByteToHex@Temp2,0 ADDWF ByteToHex@Temp3,1 BNOV Jump // Here i got syntax error 876 GOTO End_ByteToHex Jump: MOVLW 6 ADDWF ByteToHex@Temp3,1
End_ByteToHex: #endasm If I change instruction to BNZ , for example for checking , there is no error Is it compiler bug ?
NO, your error is NOT where you said it is. ;) At least it's not here with XC8 v1.45. The error is from no using ",w" and ",f" for the destination bits; i.e. replace the above with this: #asm MOVF ByteToHex@Temp2,w ADDWF ByteToHex@Temp3,f BNOV Jump GOTO End_ByteToHex Jump: MOVLW 6 ADDWF ByteToHex@Temp3,f
End_ByteToHex: #endasm
|
1and0
Access is Denied
- Total Posts : 12086
- Reward points : 0
- Joined: 2007/05/06 12:03:20
- Location: Harry's Gray Matter
- Status: offline
Re: XC8 inline asm branch instruction BNOV
2021/01/23 17:36:22
(permalink)
☄ Helpfulby Kabak 2021/02/02 03:37:10
Oh, this will save you two instruction words and cycles: #asm MOVF ByteToHex@Temp2,w ADDWF ByteToHex@Temp3,f BOV End_ByteToHex
MOVLW 6 ADDWF ByteToHex@Temp3,f
End_ByteToHex: #endasm
|
1and0
Access is Denied
- Total Posts : 12086
- Reward points : 0
- Joined: 2007/05/06 12:03:20
- Location: Harry's Gray Matter
- Status: offline
Re: XC8 inline asm branch instruction BNOV
2021/01/23 17:46:58
(permalink)
Kabak
uchar Temp3 = 0; uchar Temp = DecValue & 0xF0; uchar Temp2 = DecValue & 0x0F;
#asm MOVF ByteToHex@Temp2,0 ADDWF ByteToHex@Temp3,1 BNOV Jump // Here i got syntax error 876 GOTO End_ByteToHex Jump: MOVLW 6 ADDWF ByteToHex@Temp3,1 End_ByteToHex: #endasm
Now looking at your snippet closer, what is it supposed to do? - Temp is not used.
- Temp2 + Temp3 = low nybble + 0 will NEVER overflow.
post edited by 1and0 - 2021/01/23 17:51:21
|
Kabak
Super Member
- Total Posts : 250
- Reward points : 0
- Joined: 2014/07/30 03:47:55
- Location: 0
- Status: offline
Re: XC8 inline asm branch instruction BNOV
2021/01/24 00:48:20
(permalink)
1and0 NO, your error is NOT where you said it is. ;) At least it's not here with XC8 v1.45. The error is from no using ",w" and ",f" for the destination bits; i.e. replace the above with this:
#asm MOVF ByteToHex@Temp2,w ADDWF ByteToHex@Temp3,f BNOV Jump GOTO End_ByteToHex Jump: MOVLW 6 ADDWF ByteToHex@Temp3,f
End_ByteToHex: #endasm
You are not right. I had tried.
|
Kabak
Super Member
- Total Posts : 250
- Reward points : 0
- Joined: 2014/07/30 03:47:55
- Location: 0
- Status: offline
Re: XC8 inline asm branch instruction BNOV
2021/01/24 00:53:28
(permalink)
1and0 Oh, this will save you two instruction words and cycles:
#asm MOVF ByteToHex@Temp2,w ADDWF ByteToHex@Temp3,f BOV End_ByteToHex
MOVLW 6 ADDWF ByteToHex@Temp3,f
End_ByteToHex: #endasm
Thank you. Your optimisation works perfectly and without changing destination to w or f Seems developers decide to not implement BNOV cause BOV do almost the same ;)
post edited by Kabak - 2021/01/24 00:54:58
|
ric
Super Member
- Total Posts : 29870
- Reward points : 0
- Joined: 2003/11/07 12:41:26
- Location: Australia, Melbourne
- Status: online
Re: XC8 inline asm branch instruction BNOV
2021/01/24 01:09:03
(permalink)
☄ Helpfulby Kabak 2021/02/02 03:37:46
Update your copy of XC8. It fails for you with v1.33. I can verify that v1.34 and v1.35 do not recognise BNOV, but v1.45 does recognise it. So yes, it WAS a compiler bug, but was fixed years ago.
To get a useful answer, always state which PIC you are using!
|
ric
Super Member
- Total Posts : 29870
- Reward points : 0
- Joined: 2003/11/07 12:41:26
- Location: Australia, Melbourne
- Status: online
Re: XC8 inline asm branch instruction BNOV
2021/01/24 01:12:58
(permalink)
and here's the documentation, from the README file for v1.45, saying it was fixed in v1.42
5.4. Version 1.42Missing PIC18 instruction from assembler (XC8-1550) The PIC18 assembler used a bnv instruction instead of bnov, as documented in the device data sheet. Both instruction mnemonics are now accepted.
post edited by ric - 2021/01/24 01:14:22
To get a useful answer, always state which PIC you are using!
|
Kabak
Super Member
- Total Posts : 250
- Reward points : 0
- Joined: 2014/07/30 03:47:55
- Location: 0
- Status: offline
Re: XC8 inline asm branch instruction BNOV
2021/01/24 01:38:14
(permalink)
BNV works for XC8 1.33 It remains a mystery why they replaced BNOV with BNV ( in datasheet mentioned BNOV, no BNV exist ) Thank you, ric
post edited by Kabak - 2021/01/24 01:44:08
|
1and0
Access is Denied
- Total Posts : 12086
- Reward points : 0
- Joined: 2007/05/06 12:03:20
- Location: Harry's Gray Matter
- Status: offline
Re: XC8 inline asm branch instruction BNOV
2021/01/24 01:48:21
(permalink)
Kabak It remains a mystery why they replaced BNOV with BNV ( in datasheet mentioned BNOV, no BNV exist )
Why it's a mystery? It's software and software has bugs. ;) Have you read my Post #6?
|
Kabak
Super Member
- Total Posts : 250
- Reward points : 0
- Joined: 2014/07/30 03:47:55
- Location: 0
- Status: offline
Re: XC8 inline asm branch instruction BNOV
2021/01/24 01:59:46
(permalink)
1and0
Kabak It remains a mystery why they replaced BNOV with BNV ( in datasheet mentioned BNOV, no BNV exist )
Why it's a mystery? It's software and software has bugs. ;)
Have you read my Post #6?
Yes, actually i have provided not whole code. May be you have time to help me optimeze it. In DS3231 time storing as decimal value in hex form. Example : Time 23:15:00 = 0x23 0x15 0x00 for some calculations i need to convert time value from real HEX value into DS3231 decimal in hex form :) uchar DS3231_ByteToHexTime ( uchar DecValue ) { uchar Temp3 = 0; uchar Temp = DecValue & 0xF0; uchar Temp2 = DecValue & 0x0F; asm ("SWAPF DS3231_TimeByteToDec@Temp, 1, 0");
switch ( Temp ) { case 1: Temp3 = 0x16; break; case 2: Temp3 = 0x32; break; case 3: Temp3 = 0x48; break; default:; }
#asm MOVF DS3231_ByteToHexTime@Temp2,0 ADDWF DS3231_ByteToHexTime@Temp3,1 BNV End_ByteToHexTime MOVLW 6 ADDWF DS3231_ByteToHexTime@Temp3,1
End_ByteToHexTime: #endasm return ( Temp3 ); }
post edited by Kabak - 2021/01/24 02:01:09
|
1and0
Access is Denied
- Total Posts : 12086
- Reward points : 0
- Joined: 2007/05/06 12:03:20
- Location: Harry's Gray Matter
- Status: offline
Re: XC8 inline asm branch instruction BNOV
2021/01/24 02:23:51
(permalink)
Kabak Yes, actually i have provided not whole code. May be you have time to help me optimeze it.
Before I put any time into this, which maybe hours later, you'll have to provide some more details. Kabak In DS3231 time storing as decimal value in hex form. Example : Time 23:15:00 = 0x23 0x15 0x00
I've not read theDS3231 datasheet. So the format is in packed BCD, correct? Kabak for some calculations i need to convert time value from real HEX value into DS3231 decimal in hex form :)
By "real HEX value", you meant binary? That is, you want decimal number 23 to be convert to 0x23, correct? Kabak
uchar DS3231_ByteToHexTime ( uchar DecValue ) { uchar Temp3 = 0; uchar Temp = DecValue & 0xF0; uchar Temp2 = DecValue & 0x0F; asm ("SWAPF DS3231_TimeByteToDec@Temp, 1, 0");
switch ( Temp ) { case 1: Temp3 = 0x16; break; case 2: Temp3 = 0x32; break; case 3: Temp3 = 0x48; break; default:; }
#asm MOVF DS3231_ByteToHexTime@Temp2,0 ADDWF DS3231_ByteToHexTime@Temp3,1 BNV End_ByteToHexTime MOVLW 6 ADDWF DS3231_ByteToHexTime@Temp3,1
End_ByteToHexTime: #endasm return ( Temp3 ); }
Does your function work?
|
1and0
Access is Denied
- Total Posts : 12086
- Reward points : 0
- Joined: 2007/05/06 12:03:20
- Location: Harry's Gray Matter
- Status: offline
Re: XC8 inline asm branch instruction BNOV
2021/01/24 02:31:53
(permalink)
Does your function work? I asked that question because: asm ("SWAPF DS3231_TimeByteToDec@Temp, 1, 0"); Where is this Temp variable from? That name is another function name. MOVF DS3231_ByteToHexTime@Temp2,0 ADDWF DS3231_ByteToHexTime@Temp3,1 BNV End_ByteToHexTime
Temp2 has max value of 0x0F, Temp3 has max value of 0x48, and their sum will NEVER overflow; so why bother testing the OV bit?
|
Kabak
Super Member
- Total Posts : 250
- Reward points : 0
- Joined: 2014/07/30 03:47:55
- Location: 0
- Status: offline
Re: XC8 inline asm branch instruction BNOV
2021/01/24 02:42:50
(permalink)
So the format is in packed BCD, correct? Yes By "real HEX value", you meant binary? That is, you want decimal number 23 to be convert to 0x23, correct? Yes
|
Kabak
Super Member
- Total Posts : 250
- Reward points : 0
- Joined: 2014/07/30 03:47:55
- Location: 0
- Status: offline
Re: XC8 inline asm branch instruction BNOV
2021/01/24 02:47:11
(permalink)
..
post edited by Kabak - 2021/01/24 03:41:49
|
Kabak
Super Member
- Total Posts : 250
- Reward points : 0
- Joined: 2014/07/30 03:47:55
- Location: 0
- Status: offline
Re: XC8 inline asm branch instruction BNOV
2021/01/24 03:04:34
(permalink)
Temp2 has max value of 0x0F, Temp3 has max value of 0x48, and their sum will NEVER overflow; so why bother testing the OV bit? Seems i mix up DC with OV bit 1 DC: Digit carry/borrow bit (ADDWF, ADDLW,SUBLW,SUBWF instructions) (for borrow, the polarity is reversed) 1 = A carry-out from the 4th low order bit of the result occurred 0 = No carry-out from the 4th low order bit of the result
There is no DC status bit branching in PIC18F26k22
post edited by Kabak - 2021/01/24 03:39:54
|
blue_led
New Users
- Total Posts : 89
- Reward points : 0
- Status: offline
Re: XC8 inline asm branch instruction BNOV
2021/01/24 03:11:56
(permalink)
1and0 I've not read theDS3231 datasheet. So the format is in packed BCD, correct?
Kabak In DS3231 time storing as decimal value in hex form. Example : Time 23:15:00 = 0x23 0x15 0x00
I've not read theDS3231 datasheet. So the format is in packed BCD, correct? Kabak for some calculations i need to convert time value from real HEX value into DS3231 decimal in hex form :)
1and0 you are right. I think OP want to convert seconds ( maybe UNX time, who knows ) stored as hex value into packed BCD. That is right ? Before any help we need to know what OP want to do. @ Kabak There is very eficient ways to convert bin to BCD or BCD to bin. Search with google for Double Dabble (shift-add-three) and reverse Double Dabble. I did not see in your code that you take into account the fact that the seconds roll over from 59
post edited by blue_led - 2021/01/24 03:15:41
|
Kabak
Super Member
- Total Posts : 250
- Reward points : 0
- Joined: 2014/07/30 03:47:55
- Location: 0
- Status: offline
Re: XC8 inline asm branch instruction BNOV
2021/01/24 03:27:48
(permalink)
blue_led . . . @ Kabak There is very eficient ways to convert bin to BCD or BCD to bin. Search with google for Double Dabble (shift-add-three) and reverse Double Dabble. I did not see in your code that you take into account the fact that the seconds roll over from 59
I want to make an countdown indication on LCD. Timer. So, 1) To set a timer I should read actual time from DS3231 2) Add required Timer value to actual time now ( For example 10 minutes and 30 seconds ) 3) Start countdown on the LCD screen I need to calkulate remaining timer value and display it on LCD, so i need permanetly read actual time and subtract it value from final Timer value May be you know better and faster way to do so ?
|