Bcd - Commands !!link!!
mov al, 0x45 ; BCD 45 add al, 0x27 ; BCD 27 → binary result 0x6C daa ; adjusts to 0x72 (BCD 72)
| Instruction | Description | Operands | |-------------|-------------|----------| | | Decimal Adjust AL after Addition (packed BCD) | implicit (AL) | | DAS | Decimal Adjust AL after Subtraction (packed BCD) | implicit (AL) | | AAA | ASCII Adjust after Addition (unpacked BCD) | implicit (AL, AH) | | AAS | ASCII Adjust after Subtraction (unpacked BCD) | implicit (AL, AH) | | AAM | ASCII Adjust after Multiply (unpacked) | implicit (AX) | | AAD | ASCII Adjust before Division (unpacked) | implicit (AX) | bcd commands
uint8_t bcd_add(uint8_t a, uint8_t b) uint16_t sum = (a & 0x0F) + (b & 0x0F) + (((a >> 4) + (b >> 4)) << 4); if ((sum & 0x0F) >= 10) sum += 6; if ((sum >> 4) >= 10) sum += 0x60; return (uint8_t)sum; mov al, 0x45 ; BCD 45 add al,