00101 which obviously would be equal to 5
100101 which would be equal to 37
To solve this you need two values:
- The bit value given above, here named
val
- The count of bits in the value (because it is not a regular value like 8,16,...), here named
len
Then you can get the final value by using the following formula:
result = val | (1 << len)
In your case this would be
result = 00101b | (1 << 5d) = 00101b | 100000b = 100101b
In x86 assembly (Intel MASM syntax) this could be done like this
mov eax, val ; EAX = 00000101
mov ecx, len ; ECX = 5
mov edx, 1 ; EDX = 00000001
shl edx, cl ; EDX = 00100000
or eax, edx ; EAX = 00100101