8086 programs Flashcards
16bit addition
MOV AX,1111H
MOV BX,2222H
ADD AX,BX
MOV [2000],AX
HLT
F4
16 bit subtraction
MOV AX,2222H
MOV BX,1111H
SUB AX,BX
MOV [2002],AX
HLT
16 bit multiplication
MOV AX,3H
MOV BX,2H
MUL BX
MOV [2004],AX
HLT
16 bit division
MOV AX,0006H
MOV BX,0003H
DIV BX
MOV [2006],AX
HLT
addition with carry using condition
To add two 16 bit numbers stored in [1200H]-[1201H] and [1202H]-[1203H]
MOV AX,[1200]
MOV BX,[1202]
MOV CL,00
ADD AX,BX
JNC 104D
INC CL
MOV [2008],AX
MOV [200A],CL
HLT
average of three numbers
MOV BX,3H
MOV AX,2H
ADD AX,2H
ADD AX,2H
DIV BX
MOV [2200], AX
HLT
sum of array of numbers
MOV CX,05H
MOV AX, 0000H
MOV BX, 0000H
MOV SI,3200
REPEAT: MOV BL,[SI]
ADD AX, BX
INC SI
DEC CX
JNZ REPEAT
JNZ 1227
MOV DI, 2202H
MOV [DI],AX
HLT
sum of corresponding elements of two arrays
MOV SI,3206
MOV CL, [SI]
MOV CH, 00H
INC SI
MOV DI, 3217
MOV SI,3206
MOV CL, [SI]
MOV CH, 00H
INC SI
MOV DI, 3217
MOV AL,[SI]
ADD AL,[DI]
MOV [SI], AL
INC SI
INC DI
LOOP 1244
HLT