5. (20) Write an ARM assembly language code segment that will input a four-bit b
ID: 3700187 • Letter: 5
Question
5. (20) Write an ARM assembly language code segment that will input a four-bit binary variable x. Use port B for your input port. This variable is associated with the first four bits of the port (low nibble, bits 0-3); whereas the other four (high nibble, bits 4-7) are unaccounted for and will therefore be allowed to float. You must account for this in your code. Once the port is read and masked appropriately it will then pass this value into a function that multiplies this variable, x by 10 (decimal) using shifts and adds or subtracts (and not the MUL or UMULL instructions.) Following the computation it will output the binary result to the 8-bit port C. The program will continuously monitor (poll) the input port and update the output port accordingly. Write a flow chart and assembly language program using indiredt addressing mode instructions (pointers) for input and output, and available arithmetic instructions to solve the problem. 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 8-bit ports as PORTB and PORTC in your program.Explanation / Answer
flow-chart:
1. start
2. load register with value from memory(PORTB)
3.perform AND operation with register
4. store result from register to memory(PORTC)
Assembly program:
TTL splitbyte
AREA program ,code,READONLY
ENTRY
Main
LDRB R1,PORTB
LDRB R2,mask
MOV R3,R1,LSB#0X4
MOV R3,R3, LSL#X04
AND R1,R1,R2
ADD R1,R1,R3
STR R1,PORTC
BL multi
SWI %11
PORTB DCB %F4
ALIGN
mask DCW %0F
ALIGN
PORTC DCD 0
END
subroutine :
multi LDB R0,[LR]
MOV R2,R0,LSL#10
MOV R2 LR
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.