16F48A Microcontroller, 155 bytes
IN Q,s0
MOVI s0,s1
MOVI s2,00
MOVI s3, 09
A: INC s2
SHR s1
JNZ A
B: DEC s3
DEC s1
JNZ B
C: MOVI s3,s4
SHL s0
DEC s3
JNZ C
D: DEC s4
SHR s0
JNZ D
OUT s0
explanation:
This particular microcontroller takes inputs in binary, starting at the top of the code and working its way down. It can only use 9 registers (s0 through s8, but cannot output s8) and each of those registers can store 8 bits - again, in binary.
The first section takes the input and sets some values for later use.
section A shifts the input right, effectively removing bytes at the end, until it reaches zero, all the while, s2 is keeping track of how many shifts have taken place.
Section B then takes the amount of right shifts from 9, to determine how many times to shift left until the front byte that is a 1 has been removed.
Section C actually shifts left, but saves the amount of shifts to be able to shift right again.
Finally, section D shifts it right, to move it to the original position, minus the first 1.
19Clearing the most significant bit from
10
obviously gives0
:D – clabacchio – 2017-11-15T10:26:02.947@clabacchio I.. it... er... wha? (nice one) – Baldrickk – 2017-11-15T10:46:04.663
12It seems to me that the zeroes are just as significant as the ones. When you say "the most significant bit" you mean "the most significant bit that is set to one". – Michael Kay – 2017-11-16T18:54:45.940