How to sum up 24-bit numbers on assembler?
If the assembler for x86 means.
If the numbers are "correct" - i.e. NOT MORE 2 ^ 24-1 then you can add a check and set the carry flag (CF) depending on whether the result value exceeds 2 ^ 24-1.
for example (when working with 32-bit operands, EAX, EBX operands, the result in EAX)
ADD EAX, EBX; TEST EAX, 0x01000000; JZ ncarry; AND EAX, 0x00FFFFFF; STC; ncarry: ...
as a result, in EAX, the “correct” (truncated) 24-bit number, in the CF flag - overflow with 24-bit addition (if any.
For 16-bit registers will have to modify the code. In particular, replace the first command with the appropriate sequence of commands for addition and change the TEST command: Operands - AX: BX (BX-Jr), CX: DX, result in AX: BX:
ADD BX, DX; ADC AX, CX; TEST AX, 0x0100; JZ ncarry; AND AX, 0x00FF; STC; ncarry: ...
For assembler, ARM processors are still simplified - there is support for conditional execution of commands, that is, the need for a conditional transition disappears ...
fold the younger parts see CF fold the senior parts to fit CF
because Since 32-bit processors, it is not forbidden to add 2x 24-bit numbers as 32-bit ones.