Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The program attached below shows a call to the subroutine BCD2Hex. BCD2Hex is a subroutine that converts InputBCD, a 2-digit number in BCD representation, to
The program attached below shows a call to the subroutine BCD2Hex. BCD2Hex is a subroutine that converts InputBCD, a 2-digit number in BCD representation, to hexidecimal representation. The hexadecimal representation is stored in OutputHex after the execution of the subroutine (e.g., in this example InputBCD = 54, OutputHex = 36). The value stored in the InputBCD register cannot be changed in the subroutine. Implement the subroutine BCD2Hex. Consider using swapf in your implementation (datasheet description provided below), and appropriate logic and multiplication operations. Take a photo of the code you have written and upload your answer. InputBCD equ 0x00 2 OutputHex equ Ox01 3 Temp equ Ox02 4 5 org 0x000000 6 goto Main 7 8 Main: movlw Ox54 9 movwf InputBCD, A 10 call BCD2 Hex 11 bra s 12 BCD2Hex: ;Your code should be written here. 13 14 return 15 16 17 end SWAPF Syntax: Operands: Swap f [ label] SWAPF f[,d [,a] Osts 255 de [0,1] a [0,1] (f) dest, (f) dest None Operation: Status Affected: Encoding: Description: 0011 10da ffff ffff The upper and lower nibbles of reg. ister 'f' are exchanged. If 'd' is O, the result is placed in W. If 'd' is 1, the result is placed in register 'f' (default). If'a' is 0, the Access Bank will be selected, overriding the BSR value. If 'a' is 1, then the bank will be selected as per the BSR value (default). 1 1 Words: Cycles: Q Cycle Activity: Q1 Decode Q3 Q2 Read register 'f' Process Data Q4 Write to destination REG, 1, 0 Example: SWAPF Before Instruction REG Ox53 After Instruction REG Ox35
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started