To convert from ASCII to unpacked BCD, you have to follow the following steps:
1- Load the ASCII code of the decimal digit in AL, AH, BL, BH, CL, CH, DL, or DH register.
2- AND the contents of the register with 0FH. After this step, you will have the unpacked BCD digit in one byte.
3- Store the contents of the register into the unpacked BCD array.
4- Repeat from step 1 until all ASCII codes have been converted.
To convert from ASCII to packed BCD, you have to follow the following steps:
1- Load the ASCII code of the decimal digit and the adjacent digit in AX, BX, CX, or DX.
2- AND the contents of the register with 0F0FH. After this step, you will have two unpacked BCD digits, each in an 8-bit register.
3- Shift left the contents of the high half of the register 4-bit positions like this: MOV CL, 4 SHL register name, CL.
4- Convert the contents of the two halves of the register into packed BCD by using the OR instruction: OR low half of register, high half of register. In the result, you will have packed BCD.
5- Store the contents of the register into the packed BCD array.
6- Repeat from step 1 until all ASCII codes have been converted.