This code takes DE has a hexadecimal number in ASCII and converts it to binary in A. It assumes that DE is a valid hexadecimal number and uses uppercase 'A' through 'F'. It will fail if lowercase letters are used or any ASCII character outside of '0' .. '9' and 'A' .. 'F'.
HexToNum ld a,d
call Hex1
add a,a
add a,a
add a,a
add a,a
ld d,a
ld a,e
call Hex1
or d
ret
Hex1 sub a,'0'
cp 10
ret c
sub a,'A'-'0'-10
ret
Update: Have now tested code and fixed bug in handling of 'A' .. 'F' case in Hex1.
Update: Using "add a,a" which is faster than "sla a". Note that if speed is a concern both conversions can be done much more quickly with lookup tables.