Page 1 of 1

log bug?

Posted: Sun Jul 10, 2016 4:45 pm
by igorp
I think. spin asm log function compiling wrong

LOG C * LOG(|ACC|) + D , there D is 4.6 real format

Example

program:

Code: Select all

        LOG         0.5 , 0  
        LOG         0.5 , 0.5 
        LOG         0.5 , -0.5
        LOG         0.5 , 1.5
        LOG         0.5 , -1.5
        LOG         0.5 , 2.5
        LOG         0.5 , -2.5
        LOG         0.5 , 4.5  
        LOG         0.5 , -4.5  
        LOG         0.5 , 8.5  
        LOG         0.5 , -8.5  
        LOG         0.5 , 15.5
        LOG         0.5 , -15.5
.file and binary:

Code: Select all

log_test2_00[] = {
0x20,0x00,0x00,0x0B,
0x20,0x00,0x40,0x0B,
0x20,0x00,0xC0,0x0B,
0x20,0x00,0xC0,0x0B,
0x20,0x00,0x40,0x0B,
0x20,0x00,0x40,0x0B,
0x20,0x00,0xC0,0x0B,
0x20,0x00,0x40,0x0B,
0x20,0x00,0xC0,0x0B,
0x20,0x00,0x40,0x0B,
0x20,0x00,0xC0,0x0B,
0x20,0x00,0xC0,0x0B,
0x20,0x00,0x40,0x0B,
...
as you can see, binary ouput is the same for D=0.5, 1.5, etc.

That is the problem? spin asm version 1.1.31.0

Posted: Mon Jul 11, 2016 5:03 am
by igorp
one more test

Code: Select all

       LOG         0.666 , 0
        LOG         0.666 , 0.5
        LOG         0.666 , 1
        LOG         0.666 , 2
        LOG         0.666 , 4
        LOG         0.666 , 8
        LOG         0.666 , 15
dump:

Code: Select all

0x2A,0x9F,0x00,0x0B,
0x2A,0x9F,0x40,0x0B,
0x2A,0x9F,0x80,0x0B,
0x2A,0x9F,0x00,0x0B,
0x2A,0x9F,0x00,0x0B,
0x2A,0x9F,0x00,0x0B,
0x2A,0x9F,0x80,0x0B,
bit code of argument D is

Code: Select all

D=00000000000  // 0
D=01000000000  // 0.5
D=10000000000  // -1 ???
D=00000000000  // 0
D=00000000000  // 0
D=00000000000  // 0
D=10000000000  // -1 ??
So, the integer part of argument D is compiling wrong, or something like that. But parser working fine, I cant make D higher, than 15.9

Posted: Tue Jul 12, 2016 11:22 am
by frank
Yeah, looks like a bug in the assembler. Simple work around is to divide the desired value by 16 to use in the instruction and it will map into the instruction bits properly then.

I.e. if you wanted D=-9.3 then enter it as -0.58215 (-9.3/16) in the instruction and it appears to map properly in the instruction.

Posted: Tue Jul 12, 2016 3:43 pm
by igorp
Thanks, Frank!

Posted: Sun Aug 14, 2016 8:36 am
by MacroMachines
Oh, hmm I wonder if this has been part of my confusion also.

is it valid to use xx/16 in the code for equ or sof etc?

Posted: Sun Aug 14, 2016 10:16 pm
by frank
Well, you could use xx/16 any place a constant is used in the code, the assembler should do the division before creating the binary code but there shouldn't be a need to do it for other instructions. As far as I can tell it is only an issue with the assembly of the "D" part of the LOG instruction.