ADM instruction in asm

In the following code

MOV AL,NUMBER1
ADD AL,NUMBER2
MOV AH, 00H
ADC AH, 00H

for which lines 3 and 4? What are they doing?

Also, why does the code clear AH? (I assume that the AL "ADD" operation may result in a carryover.)

+4
source share
1 answer

To understand this, start by looking at what each instruction does:

, :

  • NUMBER1 AL: AL = NUMBER1

  • NUMBER2 AL: AL = NUMBER1 + NUMBER2

  • AH: AH = 0

  • AH CF, NUMBER1 NUMBER2. , AH 1, , 0 . (AH = CF)

, 16- 8- . -C :

BYTE NUMBER1;
BYTE NUMBER2;
WORD RESULT = (WORD)NUMBER1 + (WORD)NUMBER2;

BYTE WORD . ? , . 8- , , 8 .

, AL AH , , AX. , AX. 16- NUMBER1 NUMBER2.

+8

Source: https://habr.com/ru/post/1679228/


All Articles