suppose the values are similar to follows
bool a = true;
address b=0x5B38Da6a701c568545dCfcB03FcB875f56beddC4;
then the slot 0 value would be
>> 0x00000000000000000000005b38da6a701c568545dcfcb03fcb875f56beddc401
Right most digit would be the bool value.
To extract the address,
- load the slot 0
- extract only the address and shifting right
contract MyContract{
bool a = true;
address b=0x5B38Da6a701c568545dCfcB03FcB875f56beddC4;
function getAddress() public view returns (address){
assembly {
mstore(0x40, shr(8, and(sload(0),0x00000000000000000000ffffffffffffffffffffffffffffffffffffffffff00)))
return(0x40, 0x60)
}
}
}
and operation zero out the bool and possible other values gives a result as follows
>> 0x00000000000000000000005b38da6a701c568545dcfcb03fcb875f56beddc400
Then 8 bits are shifted right to get the result as follows
>> 0x0000000000000000000000005b38da6a701c568545dcfcb03fcb875f56beddc4