Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You have to write an assembly program that will perform addition and subtraction

ID: 2293442 • Letter: Y

Question

You have to write an assembly program that will perform addition and subtraction of two decimal numbers.  The two numbers should be located somewhere in memory, but should not be random numbers: they must be read from the DIP switch when you press switch PA0.  Note that this is similar to Lab #4.  The lower 4 bits read from the DIP switch (i.e. Port C) will be digit 0 and the higher 4 bits will be digit 1.  Note that each number can be 010– 1510.   The RMB directive may be useful for reserving a memory byte.  The result of the addition and the subtraction should be also stored in memory (of course, in two different memory location, one for each result).  Each result should be displayed in the seven segment displays.   Each result will be displayed only until switch PA0 is depressed, i.e. after entering the numbers in the DIP switch, and pressing PA0, the result of the addition is shown at the seven-segment display. One more click of the PA0 button should show the result of the subtraction.  The next PA0 will read the next number and display the addition, so on and so forth.  

Extra credit option (10%):Do without the PA0 switch to control the display Instead, insert a 1 second delay between displaying the result of addition and subtraction. You still need  the PA0 switch to enter the numbers from the DIP switch.

Every time you load a new number a software interrupt should be generated.  You will need to write an SWI handler (i.e. the software interrupt subroutine) that will keep track of how many new numbers have been loaded from the DIP switch and stop operation as soon as we reach 10 numbers.  Since every time we load bits from the DIP in port C we are really loading two digits, you will only be able to do each addition and each subtraction 5 times.

Explanation / Answer

Addition of decimal no.

.model small
.stack 100h

.code

main proc


mov ah,1
Int 21h

mov bl, al

Int 21h
mov cl, al

ADD bl, cl

mov ah, 2
mov dl, bl
Int 21h


mov ah, 4ch
Int 21h

main endp

end main

Sustraction programme
data segment
a db 2Ah
b db 13h
c dw ?
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov al,a
mov bl,b
sub al,bl
mov c,ax
int 3
code ends
end start

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote