Question: Write an assembly program to achieve the addition of two numbers entered to port B and display the result on port A . 1 .

Write an assembly program to achieve the addition of two numbers entered to port B and display the result on port A.1.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.2. 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)).3. After that we add the two numbers using the instruction ADDWF F,d and then we display the result on PORTA

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!