6. (15) Write an ARM assembly language code segment that will compute 4-bit binary signed-magnitude subtraction. Use all
Posted: Fri May 20, 2022 10:43 pm
6. (15) Write an ARM assembly language code segment that will compute 4-bit binary signed-magnitude subtraction. Use all of Port B for inputs and outputs; where the first nibble (PBO – PB3) represents the subtrahend (bottom number), the second nibble (PB4 - PB7) represents the minuend (top number), and the third nibble (PB8 – PB11) represents the difference. Remember in subtraction that: Difference = Minuend - Subtrahend. The program needs to output the signed magnitude result (not the twos- compliment result) to the output pins. If the result is negative, port B, bit 12 (PB12) should be activated (turned on) to represent a negative sign, otherwise PB12 should be turned off to represent a positive result. The program will continuously monitor (poll) the input and update the output accordingly. Use indirect addressing mode instructions for reading the input and writing to the output. You do not need to set up the ports (DDR, Clock, etc.), simply use them as you can assume that they have been taken care of beforehand using a device driver routine. You should refer to the 16-bit port as PORTB in your program.