ADDITION, SUBTRACTION AND COMPARISON in ASSEMBLY LANGAGE
ADD (Addition) • This is used to add byte/word of data of 2 registers or a register & a memory-location • The only types of addition not allowed are memory-to-memory and segment register (Table 5-1). Register Addition • Whenever arithmetic and logic instructions execute, the contents of the flag-register changes. • Any ADD instruction modifies contents of sign, zero, carry, auxiliary, carry, parity & overflow flags. Example 5-1: Program to compute AX=BX+CX+DX. ADD AX,BX ADD AX,CX ADD AX,DX Immediate Addition • Immediate addition is employed whenever constant-data are added. Example 5-2: Program to add immediate data MOV DL,12H ADD DL,33H Memory-to-Register Addition Example 5-3: to add two consecutive bytes of data (stored at the data segment offset locations NUMB and NUMB+1) to the AL register. Array Addition Example 5-4: Program to add the contents of array element at indices 3, 5 and 7 MOV AL,0 ;clear sum MOV SI,3 ;address element 3 ADD AL,ARRAY[SI] ;add element 3...