For Bytes32 to 2x int128 I have working code. I've adapted code from this stack Exchange answer
function bytes32to2xint128(bytes32 z) pure public returns (int128 x, int128 y){
bytes16[2] memory tmp = [bytes16(0), 0];
assembly {
mstore(tmp, z)
mstore(add(tmp, 16), z)
}
x=int128(tmp[0]);
y=int128(tmp[1]);
}
But for the inverse, 2x int128 to Bytes32, the following doesn't work and always returns
bytes32: 0x0000000000000000000000000000000000000000000000000000000000000000
function int128x2tobytes32(int128 x, int128 y) pure public returns (bytes32 z){
assembly {
mstore(z, x)
mstore(add(z, 16), y)
}
}
Thanks in advance