Experiment No.: – 13
Aim of the Experiment: –
Implementation of a program to make a calculator.
Apparatus required: –
| Sl. No. | Name | Specification | Quantity |
|---|---|---|---|
| 1 | 8086 Microprocessor Kit | 1 no. | |
| 2 | Keyboard | 1 no. |
Algorithm : –
- Start.
- Initialize SI with 8500H.
- Initialize DI with 8600H.
- Copy the content of 6000H memory location to CX register. (Put the value 01H, 02H, 03H, 04H in 6000H memory location for addition, subtraction, multiplication and division respectively)
- Decrease CX.
- Jump if zero for addition.
- Decrease CX.
- Jump if zero for subtraction.
- Decrease CX.
- Jump if zero for multiplication.
- Decrease CX.
- Jump if zero for division.
- Addition: Copy the data of 6002H memory location to CX register.
- Decrease CX.
- Copy the content of SI memory location (i.e 1st data) to AX register.
- Increase two times the value of SI register.
- Start loop: Copy the content of SI memory location (i.e 2nd data) to BX register.
- Add with carry the content of AX and BX register.
- Copy the content of AX register to the value of DI register memory location (i.e 8600H).
- Increase two times the value of SI register.
- Decrease CX.
- Jump if not zero to loop (i.e step 17).
- End for addition program.
- Subtraction: Copy the data of 6002H memory location to CX register.
- Decrease CX.
- Copy the content of SI memory location (i.e 1st data) to AX register.
- Increase two times the value of SI register.
- Start loop: Copy the content of SI memory location (i.e 2nd data) to BX register.
- Subtract with borrow the content of AX and BX register.
- Copy the content of AX register to the value of DI register memory location (i.e 8600H).
- Increase two times the value of SI register.
- Decrease CX.
- Jump if not zero to loop (i.e step 28).
- End for subtraction program.
- Multiplication: Copy the data of 6002H memory location to CX register.
- Decrease CX.
- Copy the content of SI memory location (i.e 1st data) to AX register.
- Increase two times the value of SI register.
- Start loop: Copy the content of SI memory location (i.e 2nd data) to BX register.
- Multiply the content of AX with BX register.
- Copy the content of AX register to the value of DI register memory location (i.e 8600H).
- Increase two times the value of SI register.
- Decrease CX.
- Jump if not zero to loop (i.e step 39).
- Increase two times the value of DI register.(i. e 6004H location)
- Copy the content of DX register to the value of DI register memory location (i.e 8604H).
- End for multiplication program.
- Division: Copy the data of 6002H memory location to CX register.
- Decrease CX.
- Copy the content of SI memory location (i.e 1st data) to AX register.
- Increase two times the value of SI register.
- Start loop: Copy the content of SI memory location (i.e 2nd data) to BX register.
- Divide with carry the content of AX with BX register.
- Copy the content of AX register to the value of DI register memory location (i.e 8600H).
- Increase two times the value of SI register.
- Decrease CX.
- Jump if not zero to loop (i.e step 52).
- Increase two times the value of DI register.(i. e 6004H location)
- Copy the content of DX register to the 8604H memory location through DI register.
- End for division program.
Program: –
| Memory Address | Mnemonics | Opcode | Comments |
|---|---|---|---|
| 1000:0100 | MOV SI, 8500H | BE 00 85 | SI<—-8500H |
| 1000:0103 | MOV DI, 8600H | BF 00 86 | DI<—-8600H |
| 1000:0106 | MOV CX,[6000H] | 8B 0E 00 60 | CX<—-[6000]H |
| 1000:010A | DEC CX | 49 | Decrease CX |
| 1000:010B | JZ ADDITION | 74 09 | Jump if Zero to Addition |
| 1000:010D | DEC CX | 49 | Decrease CX |
| 1000:010E | JZ SUBTRACTION | 74 1B | Jump if Zero to Subtraction |
| 1000:0110 | DEC CX | 49 | Decrease CX |
| 1000:0111 | JZ MULTIPLICATION | 74 2D | Jump if Zero to Multiplication |
| 1000:0113 | DEC CX | 49 | Decrease CX |
| 1000:0114 | JZ DIVISION | 74 43 | Jump if Zero to Division |
| 1000:0116 | ADDITION: MOV CX, [6002H] | 8B 0E 02 60 | CX<—[6002H] |
| 1000:011A | DEC CX | 49 | Decrease CX |
| 1000:011B | MOV AX,[SI] | 8B 04 | AX<—[SI] |
| 1000:011D | INC SI | 46 | Increase SI |
| 1000:011E | INC SI | 46 | Increase SI |
| 1000:011F | LOOP:MOV BX,[SI] | 8B 1C | Loop: B<—[SI] |
| 1000:0121 | ADC AX,BX | 13 C3 | AX<—AX+BX |
| 1000:0123 | MOV [DI],AX | 89 05 | [DI]<—AX |
| 1000:0125 | INC SI | 46 | Increase SI |
| 1000:0126 | INC SI | 46 | Increase SI |
| 1000:0127 | DEC CX | 49 | Decrease CX |
| 1000:0128 | JNZ LOOP | 75 F5 | Jump if not zero to loop |
| 1000:012A | INT A5 / HLT | F4 | Stop |
| 1000:012B | SUBTRACTION: MOV CX, [6002H] | 8B 0E 02 60 | CX<—[6002H] |
| 1000:012F | DEC CX | 49 | Decrease CX |
| 1000:0130 | MOV AX,[SI] | 8B 04 | AX<—[SI] |
| 1000:0132 | INC SI | 46 | Increase SI |
| 1000:0133 | INC SI | 46 | Increase SI |
| 1000:0134 | LOOP2: MOV BX,[SI] | 8B 1C | Loop2: BX<—[SI] |
| 1000:0136 | SBB AX,BX | 1B C3 | AX<—AX-BX |
| 1000:0138 | MOV [DI],AX | 89 05 | [DI]<—AX |
| 1000:013A | INC SI | 46 | Increase SI |
| 1000:013B | INC SI | 46 | Increase SI |
| 1000:013C | DEC CX | 49 | Decrease CX |
| 1000:013D | JNZ LOOP2 | 75 F5 | Jump if not zero to loop2 |
| 1000:013F | INT A5 / HLT | F4 | Stop |
| 1000:0140 | MULTIPLICATION: MOV CX, [6002H] | 8B 0E 02 60 | CX<—[6002H] |
| 1000:0144 | DEC CX | 49 | Decrease CX |
| 1000:0145 | MOV AX,[SI] | 8B 04 | AX<—[SI] |
| 1000:0147 | INC SI | 46 | Increase SI |
| 1000:0148 | INC SI | 46 | Increase SI |
| 1000:0149 | LOOP3: MOV BX,[SI] | 8B 1C | Loop3: BX<—[SI] |
| 1000:014B | MUL BX | F7 E3 | AX<—AX x BX |
| 1000:014D | MOV [DI],AX | 89 05 | [DI]<—AX |
| 1000:014F | INC SI | 46 | Increase SI |
| 1000:0150 | INC SI | 46 | Increase SI |
| 1000:0151 | DEC CX | 49 | Decrease CX |
| 1000:0152 | JNZ LOOP3 | 75 F5 | Jump if not zero to loop3 |
| 1000:0154 | INC DI | 47 | Increase DI |
| 1000:0155 | INC DI | 47 | Increase DI |
| 1000:0156 | MOV [DI],DX | 89 15 | [DI]<—DX |
| 1000:0158 | INT A5 / HLT | F4 | Stop |
| 1000:0159 | DIVISION: MOV CX, [6002H] | 8B 0E 02 60 | CX<—[6002H] |
| 1000:015D | DEC CX | 49 | Decrease CX |
| 1000:015E | MOV AX,[SI] | 8B 04 | AX<—[SI] |
| 1000:0160 | INC SI | 46 | Increase SI |
| 1000:0161 | INC SI | 46 | Increase SI |
| 1000:0162 | LOOP4:MOV BX,[SI] | 8B 1C | Loop4: [BX]<—[SI] |
| 1000:0164 | DIV BX | F7 F3 | AX<—AX/BX |
| 1000:0166 | MOV [DI],AX | 89 05 | [DI]<—AX |
| 1000:0168 | INC SI | 46 | Increase SI |
| 1000:0169 | INC SI | 46 | Increase SI |
| 1000:016A | DEC CX | 49 | Decrease CX |
| 1000:016B | JNZ LOOP4 | 75 F5 | Jump if not zero to loop4 |
| 1000:016D | INC DI | 47 | Increase DI |
| 1000:016E | INC DI | 47 | Increase DI |
| 1000:016F | MOV [DI],DX | 89 15 | [DI]<—DX |
| 1000:0171 | INT A5 / HLT | F4 | Stop |
\[\color\green{ Put\; 01H,\;02H,\;03H,\;04H\; into\;}\]
\[\color\green{ 6000H\; memory\;location\;for}\]
\[\color\red{Addition,\;Subtraction,\;Multiplication,\; and\;Division}\]
\[\color\green{ Put\;number\; of\;data\; into\; 6002H\; memory\;location}\]
\[\color\magenta{ Put\;input\;data\; into\; 8500H\; memory\;location\; onwards}\]
\[\color\magenta{ Get\;output\; from\;8600H\; memory\;location\;onwards}\]
Conclusion: –
To be written by student.