In this experiment ew will implement the Addition and Subtra

In this experiment ew will implement the Addition and Subtraction Functions Using PIC 16F84A microcontroller. Addition and subtraction functions The addition function is summarized as follow: We use the method of masking to separate the two numbers. since the first number is in the LSB of PORTB and the second number is in the MSB. we separate the first number using the instruction ANDLW 0X0F, and the second number using the instruction ANDLW 0XF0. After that before we add the two numbers, the first number is ready for addition but the second number needs to be swapped, so we use the instruction SWAPF F.d to swap it (swapping means F(0:3) = F(4:7), F(4:7) = F(0:3)). After that we add the two numbers using the instruction ADDWF F.d and then we display the result on PORTA. The subtraction function is the same as the addition function except you will subtract the two numbers instead of adding them. To avoid negative answer the first number must be greater than the second Write an assembly program to achieve the subtraction of numbers entered port B and display the result on port A Simulate the program using the circuit shown in figure via Procerus software Verify it operates properly when simulated Program a PIC 16F84A using the QI-2006 programmer Build the circuit using the programmed PIC 16F84A and then observe its operation. Demonstrate the circuits operation to the instructor.

Solution

Addition :
=============

Comments added,starting with #
#start of code.
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
#movind data tp registers
MOV sv,DATA
MOV DS,sv
#moving number 1 to AL register
MOV AL,num11
#Adding Number 2 to AL
ADD AL,num22

#Moving result to result register.
MOV rslt,AL

MOV AH,4CH
INT 21H
#End of code.
ENDS
END START


Subtraction :
=============

Comments added,starting with #
#start of code.
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
#movind data tp registers
MOV sv,DATA
MOV DS,sv
#moving number 1 to AL register
MOV AL,num11
#Subtracting Number 2 to AL
SUB AL,num22

#Moving result to result register.
MOV rslt,AL

MOV AH,4CH
INT 21H
#End of code.
ENDS
END START

 In this experiment ew will implement the Addition and Subtraction Functions Using PIC 16F84A microcontroller. Addition and subtraction functions The addition f
 In this experiment ew will implement the Addition and Subtraction Functions Using PIC 16F84A microcontroller. Addition and subtraction functions The addition f

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site