;Convert BCD number (Two digits only) in A to Binary ;No registers modified (INTEL) BCDTOBIN: PUSH B PUSH D MOV B,A ;Save it ANI 0FH ;Mask most significant four bits MOV C,A ;Save unpacked BCDI in C register MOV A,B ;Get BCD again ANI 0F0H ;Mask least significant four bits RRC ;Convert most significant four bits into unpacked BCD2 RRC RRC RRC MOV B,A ;Save unpacked BCD2 in B register XRA A ;Clear accumulator (sum = 0) MVI D,0AH ;Set D as a multiplier of 10 Sum: ADD D ;Add 10 until (B) = 0 DCR B ;Decrement BCD2 by one JNZ Sum ;Is multiplication complete? i if not, go back and add again ADD C ;Add BCD1 POP D POP B RET ;Return with binary value in [A]