I had weird values doing an integer divison with atmega328p.
Having a look to the int division in system.h:
sub SysDivSubInt
Dim SysCalcTempA, SysCalcTempB, SysCalcTempX As Integer Dim SysSignByte As Byte
'Make both inputs positive, decide output type
SysSignByte = SysCalcTempA_H xor SysCalcTempB_H
That generates this asm code:
SYSDIVSUBINT: eor SYSCALCTEMPB_H,SYSCALCTEMPA_H ; Now SYSCALCTEMPB_H lost its original value mov SYSSIGNBYTE,SYSCALCTEMPB_H
So the problem looks to be in the xor not correctly procesed.
As a workaround i did this:
SysSignByte = SysCalcTempB_H
SysSignByte = SysCalcTempA_H xor SysSignByte
that generates a little bloated code but working
Regards.
Log in to post a comment.
I had weird values doing an integer divison with atmega328p.
Having a look to the int division in system.h:
sub SysDivSubInt
Dim SysCalcTempA, SysCalcTempB, SysCalcTempX As Integer
Dim SysSignByte As Byte
'Make both inputs positive, decide output type
SysSignByte = SysCalcTempA_H xor SysCalcTempB_H
That generates this asm code:
SYSDIVSUBINT:
eor SYSCALCTEMPB_H,SYSCALCTEMPA_H ; Now SYSCALCTEMPB_H lost its original value
mov SYSSIGNBYTE,SYSCALCTEMPB_H
So the problem looks to be in the xor not correctly procesed.
As a workaround i did this:
SysSignByte = SysCalcTempB_H
SysSignByte = SysCalcTempA_H xor SysSignByte
that generates a little bloated code but working
Regards.