Help with 8085 entering in a number > 9

Im trying to enter in a digit between 0 and 255 and store it in a register. I understand how to use BDOS to put a keyboard value into the A register but i cant figure out how to get the right value for a 2 or 3 digit number...

Initialise some other register X to zero
1: Read the keyboard into A
Calculate the value represented (subtract the ASCII value of 0, probably, and range check it)
Error handling
X=X*10+A
Repeat from 1 until the input suggests the user has finished inputting data.