Monday, 17 June 2013

46. 16 & 32 BIT ADDITION IN 8086


16-BIT ADDITION


DATA SEGMENT
NUM DW 1234H, 0F234H
SUM DW 2 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV AX,NUM



MOV BX,0H
ADD AX,NUM+2
JNC DOWN
INC BX
DOWN: MOV SUM,AX
MOV SUM+2,BX
MOV AH,4CH
INT 21H
CODE ENDS
END START


INPUT :     1234H,   F234H
OUTPUT : 10468H




32-BIT ADDITION



DATA SEGMENT
NUM1 DW 0FFFFH,0FFFFH
NUM2 DW 1111H,1111H
SUM DW 4 DUP(0)
dATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV AX,NUM1
ADD AX,NUM2
MOV SUM,AX
MOV AX,NUM1+2
ADC AX,NUM2+2
JNC DOWN
MOV SUM+4,01H
DOWN: MOV SUM+2,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START


INPUT:     0FFFFFFFFH,      011111111H
OUTPUT: 0111111110H




32-BIT ADDITION USING DD DIRECTIVE



DATA SEGMENT
NUM1 DW 12345678H
NUM2 DW 12345678H
SUM DW 3 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
LEA SI,NUM1
LEA DI,NUM2
MOV AX,[SI]
ADD AX,[DI]
MOV CX,[SI+2]
ADC CX,[DI+2]
JNC DOWN
MOV SUM+4,01H
DOWN:MOV SUM,AX
MOV SUM+2,CX
MOV AH,4CH
INT 21H
CODE ENDS
END START


INOUT:      12345678H,     12345678H
OUTPUT:   2468ACF0H


Need the code??

No comments:

Post a Comment