Okay I've narrowed down the source of my broken math, turns out somehow alu_reg_mov() is not seeing the data:
From this function:Code:make run
cd ../ && make --no-print-directory run
#MAKECMDGOALS=run
cd mak && make -j 1 --no-print-directory -f main.mak run
PRJ_LIB_NAME=alu
Checking 3rd Party libraries are upto date
cd '../cloned/unic' && git config pull.rebase false && git pull
Finished checking
PRJ_DST_BIN=test_alu.AppImage
PRJ_DST_LIB=libalu.so
cc -D NDEBUG -fPIC -Wall -Wextra -pedantic -I ../cloned/unic/include -I ../include -D UNIC_FALLBACK -o ../src/alu_bit.o -c ../src/alu_bit.c
cc -D NDEBUG -fPIC -Wall -Wextra -pedantic -I ../cloned/unic/include -I ../include -D UNIC_FALLBACK -o ../src/alu_fpn.o -c ../src/alu_fpn.c
cc -D NDEBUG -fPIC -Wall -Wextra -pedantic -I ../cloned/unic/include -I ../include -D UNIC_FALLBACK -o ../src/alu_int.o -c ../src/alu_int.c
cc -D NDEBUG -fPIC -Wall -Wextra -pedantic -I ../cloned/unic/include -I ../include -D UNIC_FALLBACK -o ../src/alu_main.o -c ../src/alu_main.c
cc -D NDEBUG -fPIC -Wall -Wextra -pedantic -I ../cloned/unic/include -I ../include -D UNIC_FALLBACK -o ../src/alu_math.o -c ../src/alu_math.c
cc -D NDEBUG -fPIC -Wall -Wextra -pedantic -I ../cloned/unic/include -I ../include -D UNIC_FALLBACK -o ../src/alu_mem.o -c ../src/alu_mem.c
cc -D NDEBUG -fPIC -Wall -Wextra -pedantic -I ../cloned/unic/include -I ../include -D UNIC_FALLBACK -o ../src/alu_uint.o -c ../src/alu_uint.c
cc -D NDEBUG -fPIC -Wall -Wextra -pedantic -I ../cloned/unic/include -I ../include -D UNIC_FALLBACK -o ../src/alu_vec.o -c ../src/alu_vec.c
cc -D NDEBUG -fPIC -shared -o ../lib/libalu.so ../src/alu_bit.o ../src/alu_fpn.o ../src/alu_int.o ../src/alu_main.o ../src/alu_math.o ../src/alu_mem.o ../src/alu_uint.o ../src/alu_vec.o -Wl,-rpath,../lib
cc -D NDEBUG -fPIC -Wall -Wextra -pedantic -I ../cloned/unic/include -I ../include -D UNIC_FALLBACK -o ../tests/test_alu.o -c ../tests/test_alu.c
cc -D NDEBUG -fPIE -L ../lib -o ../bin/test_alu.AppImage ../tests/test_alu.o -Wl,-rpath,../lib -l alu
../bin/test_alu.AppImage
../tests/test_alu.c:921: main() Pre-allocating 64 ALU registers...
../tests/test_alu.c:371: bitwise() 'Checking Bitwise Operations...'
../tests/test_alu.c:372: bitwise() '==========================================='
../src/alu_math.c:316: mov() src = 0000000000000000000000000000000011011110101011011100000011011110
../src/alu_math.c:324: mov() s = 0, ptr = 0x55f812973320, mask = 0000000000000001, pos = 0, seg = 0, bit = 0
../src/alu_math.c:327: mov() d = 0, ptr = 0x55f812973320, mask = 0000000000000001, pos = 0, seg = 0, bit = 0
../src/alu_math.c:324: mov() s = 0, ptr = 0x55f812973320, mask = 0000000000000002, pos = 1, seg = 0, bit = 1
../src/alu_math.c:327: mov() d = 0, ptr = 0x55f812973320, mask = 0000000000000002, pos = 1, seg = 0, bit = 1
../src/alu_math.c:324: mov() s = 0, ptr = 0x55f812973320, mask = 0000000000000004, pos = 2, seg = 0, bit = 2
../src/alu_math.c:327: mov() d = 0, ptr = 0x55f812973320, mask = 0000000000000004, pos = 2, seg = 0, bit = 2
../src/alu_math.c:324: mov() s = 0, ptr = 0x55f812973320, mask = 0000000000000008, pos = 3, seg = 0, bit = 3
../src/alu_math.c:327: mov() d = 0, ptr = 0x55f812973320, mask = 0000000000000008, pos = 3, seg = 0, bit = 3
...
../tests/test_alu.c:640: uint_print_value() Error 0xFFFFFFFF -1 'Unknown error -1'
../tests/test_alu.c:858: print_value() Error 0xFFFFFFFF -1 'Unknown error -1'
../tests/test_alu.c:964: main() Error 0xFFFFFFFF -1 'Unknown error -1'
make[2]: *** [main.mak:95: test] Error 1
make[1]: *** [makefile:10: run] Error 2
make: *** [makefile:4: run] Error 2
Compilation failed.
Any ideas?Code:int alu_reg_mov(
alu_t *alu,
alu_reg_t dst,
alu_reg_t src
)
{
int ret;
void *D, *S;
alu_bit_t d, s;
size_t ndiff, vdiff, upto;
bool neg, NaN = false;
alu_reg_t DEXP, DMAN, SEXP, SMAN;
ret = alu_reg_clr( alu, dst );
if ( ret == 0 )
{
dst.node %= alu_used( alu );
src.node %= alu_used( alu );
D = alu_reg_data( alu, dst );
S = alu_reg_data( alu, dst );
/* Check for +/- */
neg = alu_reg_below0( alu, src );
if ( alu_reg_floating( src ) )
{
...
return ENOSYS;
}
ndiff = dst.upto - dst.from;
vdiff = src.upto - src.from;
alu_print_reg( __FILE__ ":" INT2STR(__LINE__) ": mov() src", alu, src, 0, 1 );
d = alu_bit_set_bit( D, dst.from );
s = alu_bit_set_bit( S, src.from );
upto = dst.from + LOWEST( ndiff, vdiff );
for ( ; d.bit < upto; alu_bit_inc(&d), alu_bit_inc(&s) )
{
alu_print_bit( __FILE__ ":" INT2STR(__LINE__) ": mov() s", s, 1 );
*(d.ptr) &= ~(d.mask);
*(d.ptr) |= SET1IF( *(s.ptr) & s.mask, s.mask );
alu_print_bit( __FILE__ ":" INT2STR(__LINE__) ": mov() d", d, 1 );
}
for ( ; d.bit < dst.upto; alu_bit_inc(&d) )
{
*(d.ptr) &= ~(d.mask);
*(d.ptr) |= SET1IF( neg, d.mask );
}
alu_print_reg( __FILE__ ":" INT2STR(__LINE__) ": mov() dst", alu, dst, 0, 1 );
return 0;
}
alu_error( ret );
return ret;
}
Edit: Just spotted that I had accidentally used dst for setting the pointer to the 1st segment of src register, rectifying that resolved my problem and all the math started behaving as expected

