Write ARM assembly language instructions to change the value of r0 as follows: • set the most significant byte of r0 to one’s (i.e., 0xFF) if the least significant byte of r1 is less than 90. • complement the least significant byte of r0 if r1 is odd.
Answer :- 1) The code to change MSB to 0xFF if LSB is less than 90 is-
AND R2, R1, #0xFF ; R2 = LSB of R1
CMP R2, #90 ; Compare R2 with 90
BGE End1 ; If value in R2 is greater than or equal to 90 then goto label named as End1
ORR R0, R0, #0xFF000000 ; If less than 90 then make MSB as 0xFF.
End1 : B End1 ; Infinite loop, end of program
Answer :- 2) To complement the LSB of R0 if R1 is odd.
AND R2, R1, #0x00000001 ; R2 = Zeroth bit of R1, for odd numbers zeroth bit is always 1. For even it will be zero.
BEQ R2, End1 ; If R2 = 0 then goto label named as End1
EOR R0, R0, #0x000000FF ; Doing xor of LSB of R0 and 0xFF to toggle the bits in lower byte
End1 : B End1 ; Infinite loop, end of program
Write ARM assembly language instructions to change the value of r0 as follows: • set the...
Write an ARM assembly program that checks bit 2 and bit 18 of R0. If the two bits are similar, then R8=R5<<2 (shift R5 left by 2 bits), otherwise clear the least most significant byte of R1.
Section B - ARM Assembly Language (25 marks) An ARM instruction set summary is provided at the end of this paper 1. (5 marks) Consider the following assembly instruction STMFD r13!, (r5-6} Before executing this instruction, registers hold the following values: Register Value Register r9 Value r4 0x00400040 0x00000000 r5 r10 0x11223344 0x00800080 r6 0x55667788 r11 0x10001000 r7 0x99aabbcc r12 0x20002000 r8 exddeeff00 r13 ex40004000 What memory locations are affected after executing the above instruction? In a table, with a...
Write an ARM assembly language program to collect the correct amount of road toll tax from a vehicle. If the vehicle is a motorbike then the correct road toll tax should be 2, otherwise the road toll tax should be 5. The vehicle type is given to you, so you don’t have to guess. Assume that someone has already put the vehicle type value in register R0. Therefore, R0 contains a value, 0 or some other value. If the value...
Mult Hack Assembly language Help me complete the assembly language fore Mult.asm. // Multiplies R0 and R1 and stores the result in R2. // (R0, R1, R2 refer to RAM[0], RAM[1], and RAM[2], respectively.) // Put your code here. // Start R2 at 0. @R2 M=0 // Jump into the first STEP if R0 > 0. @R0 D=M @STEP D;JNE // If it didn't jump, go to END. @END 0;JMP // Adds R1 to R2 and removes 1 from R0....
Write a function (subroutine) that inputs a data value in register r0 and returns value in r0. The function returns y 5 a 1 bx 1 cx2, where a, b, and c are parameters built into the function (i.e., they are not passed to it). The subroutine also performs clipping. If the output is greater than a value d, it is constrained to d (clipped). The input in r0 is a positive binary value in the range 0 to 0xFF....
Question 2 ARM Assembly Language (25 marks) An ARM instruction set summary is provided at the end of this paper. (5 marks) Explain the difference between eor and eors instruction. Use an example to show why both forms are useful. а. b. (5 marks) Explain using an example what the "Idr r3, [r7,#4]" instruction does. c. (10 marks) The following is the assembly language generated by a C compile type mystery, %function mystery: args 0, pretend = 0, frame =...
ARM assembly language Write a program "fibonacci.s" that computes the Nth Fibonacci number where N is not so large that overflow of integer arithmetic is a concern. When your assembly language program is called it should expect the value of N to be passed using register r0 and your program should return the Nth Fibonacci number in register r0. Please include comments as well. Do not just use the output generated by gcc -S
Trying to figure out how to write expression #2 in assembly language: 1. ;;X=A*C+B*D MUL R4,R0,R2 MUL R5,R1,R3 ADDS R4,R4,R5 ;;X is in R4 I believe this is correct but Im having trouble with #2 below: 2. Y=A^(B+C)+D I've been using the arm cortex m4 instruction set for reference.
1. Translate the following tasks into a single ARM instruction: a. Add 32 times of the content of registers r0 and the content of r1 only if N is clear. Store the result in register r2 b. Subtract the content of register r0 from 0x990 and put the results in register r3 only if C is set and Z is clear. c. Clear the 2nd least significant byte of the content of register r1, i.e., store (00000000)2 in it, and...
All solutions must have both code and data segments Write a sequence of assembly language instructions to subtract each entry of an array B of five two’s complement 16-bit binary integers from the corresponding entry of an array A of five two’s complement 16-bit binary integers and construct a third array C of two’s complement 16-bit binary integers. i.e. C[i] = A[i] - B[i]. Use the following data for the arrays A and B. A: 10, -15, 20, 4,...