Question: The question is based on PIC Architecture in microprocessors. The program used to build the assembly code is MPLAB X IDE. Extend and/or correct the

The question is based on PIC Architecture in microprocessors.

The program used to build the assembly code is MPLAB X IDE.

Extend and/or correct the HIPO for the comparison of 16 bit signed two's complement representation numbers provided below. (2 marks)

Write the corresponding PIC16F18877 ASM routine including the amended HIPO as comments. Include a comment that specifies the number of program memory locations, and instruction cycles your routine will require. (4 marks)

Create a test program (including your commented routine), and verify that the routine operates correctly using MPLAB-SIM or any other suitable simulator. Include a comment to explain how/why you selected your test cases. (4 marks)

For this question you must submit your final commented assembly language program (ASM), dis-assembly listing (LST), and assembled production (HEX) files.



Routine Label: lte16tc

Input: Two signed 16 bit numbers stored in two's complement representation in registers Ahi:Alo and Bhi:Blo

Process: Subtract the numbers B-A if the answer is zero or negative then B is less than or equal to A

Output: Carry flag is clear if B is less than or equal to A; otherwise Carry flag is set

step 1) find the two's complement of the number in Ahi:Alo and place it in Temphi:Templo

     step 1.1) clear Templo

     step 1.2) put value stored in Alo into working register

     step 1.3) subtract value in working register from value in Templo; answer in Templo

     step 1.4) clear TempHi

     step 1.5) put value stored in Ahi into working register

     step 1.6) subtract value in working register from value in Temphi; answer in Temphi

step 2) add Bhi:Blo to Temphi:Templo and place answer in Temphi:Templo

     step 2.1) add Blo to Templo and place answer in Templo

     step 2.2) if the Carry flag is set

          step 2.2.1) TRUE: there was a carry from the addition of the lower bytes

               step 2.2.1.1) increment the value in the register Temphi

               step 2.2.1.2) goto step 2.3

          step 2.2.2) FALSE: there was no carry from the addition of the lower bytes

               step 2.2.2.1) goto step 2.3

     step 2.3) add Bhi to Temphi and place answer in Temphi

step 3) if the (MSB of Templo is set) OR (Temphi and Templo are both zero)

     step 3.1) TRUE: the answer is either zero or negative

          step 3.1.1) clear carry flag

          step 3.1.2) goto step 4

     step 3.2) FALSE: the answer is positive

          step 3.2.1) set carry flag

          step 3.2.2) goto step 4

step 4) leave routine

Step by Step Solution

3.32 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

HIPO Input Two signed 16 bit numbers stored in twos complement representation in registers AhiAlo and BhiBlo Process Subtract the numbers BA if the an... View full answer

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 Computer Engineering Questions!