Question

In: Statistics and Probability

A block of memory contains 40 random words of data. Assume that the values are in...

A block of memory contains 40 random words of data. Assume that the values are in two’s

complement representations and are stored in the Read/Write memory area. You need to provide the

40 random words and to include them in an initialization file: assign.ini. Write a program using the

ARM assembly programming language to do the following:

a) You are required to reverse the word order in a block of 40 random words (Hint: the last word

stored in the memory becomes the first and vice versa).

b) Next, find the minimum value in the 40 random words of data.

Solutions

Expert Solution

The algorithm for reversing the order of words in memory is as follows: We have to first load the first and the last words into two registers, here R3 and R4 registers have been used. The LDR R3, [R0] instruction loads the contents of memory specified by the register R0 into the resgister R3. Then we have to swap their places. This could be done by storing the words in the registers to the respective memory locations directly. The STR R3, [R1] stores the word in register R3 into the to the memory location specified by resgister R1. This process should be repeated until we reach the middle of the list of the words that means until we run the loop for 20th time. So the loop has to be run for twenty times. The register R2 is used for this operation. The value 20 in hexadecimal is 14. The value is decremented by one everytime the loop is run and when it reaches zero the loop exits and the program is stopped. The conditional instruction BNE jumps to the specified location if the zero flag is not set.

(a)

   MOV R0, #D0 // Data stored in memory location starting from D0

   MOV R1, #F8 // storing the location of last word.

   MOV R2, #14 // number of times the loop has to run = 20 times = 14 times in hex.

LOOP LDR R3, [R0] // load the content of memory into the register

   LDR R4, [R1]

   STR R3, [R1] // store into the memory

   STR R4, [R0]

   ADD R0, R0, #1 // increment register to go to the next location

   SUB R1, R1, #1 // decement register to go to the previous location

   SUB R2, R2, #1 // Decrement the counter

   BNE LOOP    // repeat the loop if counter is not zero

For finding the minimum value we take the first value in the last and store it in register R3. Then we compare this value with all the values in the list and check if any number is less the value in register R3. If there is a lesser number then copy that number to R3 register and coontinue the process. The loop runs for 39 times to compare all the numbers. The conditional instruction BCS jumps to the specified location is the carry flag is set. The conditional instruction BNE jumps to the specified location if the zero flag is not set.

(b)

MOV R0, #D0 // Data stored in memory location starting from D0

MOV R2, #27 // number of times the loop has to run = 39 times = 27 times in hex.

  LDR R3, [R0]

LOOP    ADD R0, R0, #1 // increment register to go to the next location

LDR R4, [R0]

CMP R3, R4 // compare the register to check if the value in R4 is less

BCS NEXT // If R3 value is less then continue the loop

MOV R3, R4 // If R4 is less then copy the content of of R4 to R3

NEXT    SUB R2, R2, #1 // Decrement the counter

   BNE LOOP    // repeat the loop if counter is not zero

  

  


Related Solutions

Suppose that a block can contain at most four data values and that all data values...
Suppose that a block can contain at most four data values and that all data values are integers. Using only B+ trees of degree 2, give examples of each of the following : a. A B+ tree whose height changes from 2 to 3 when the value 42 is inserted. Show your structure before and after the insertion. b. A B+ tree in which the deletion of the value 42 leads to a redistribution. Show your structure before and after...
Data set : Data Set G: Assume the population values are normally distributed. Random variable: x...
Data set : Data Set G: Assume the population values are normally distributed. Random variable: x = weight of border collie in pounds sample size = 25 34.1 40.8 36.0 34.9 35.6 43.4 35.4 29.3 33.3 37.8 35.8 37.4 39.0 38.6 33.9 36.5 37.2 37.6 37.3 37.7 34.9 33.2 36.2 33.5 36.9 1. Choose another confidence level similar to one found in the homework (do not use the confidence level from the posted example). Based on the second confidence level,...
Assume that 20 bytes of Packed BCD data is present in a data memory at location...
Assume that 20 bytes of Packed BCD data is present in a data memory at location 0x300 to 0x313. You have to write an assembly program that will display data on a two seven segment displays one connected to Port A and other connected to Port B using loops. You also have to analyze data if the data is equal to 0x22 then start storing data bytes at corresponding memory address 0x400 to 0x413 in reverse order i.e. if the...
Memory: The table contains a subset of data reported by Barasch and colleagues (2017). Identify the...
Memory: The table contains a subset of data reported by Barasch and colleagues (2017). Identify the appropriate test to determine if taking photos of objects influences visual recognition (memory) of the objects compared with those who did not have a camera (and did not take take photos). Table: Memory Scores for Photo and No Photo Groups Note: Memory scores represent number of correct responses out of 9 total visual recognition questions Photo No Photo 5 7 7 4 8 4...
Implement a Linux Block Driver which simulates a block device with a region of memory init,...
Implement a Linux Block Driver which simulates a block device with a region of memory init, exit, and IO functionalities must be included. Please use either C or C++ Programming for this Thank You!
A set of data contains 40 observations. The lowest value is 50 and the largest is...
A set of data contains 40 observations. The lowest value is 50 and the largest is 119. The data are to be organized into a frequency distribution. a. How many classes would you suggest? b. What would you suggest as the lower limit of the first class?
What are the block tags and block indexes for the below 12-bit memory locations with 256-byte...
What are the block tags and block indexes for the below 12-bit memory locations with 256-byte cache? a. 0001 0110 1010, for 16-byte blocks with direct-mapped cache b. 0010 0011 1011, for 4-byte blocks with 4-way associative cache
A cognitive psychologist believes that memory for pictures is superior to memory for words. To test...
A cognitive psychologist believes that memory for pictures is superior to memory for words. To test this hypothesis, the psychologist performs an experiment in which students from an introductory psychology class are used as participants. Ten randomly selected students view 30 slides with nouns printed on them, and another group of eight randomly selected students views slides with pictures of the same nouns. Each slide is presented for 4 seconds. After viewing the slides, participants are given a recall test,...
A cognitive psychologist believes that memory for pictures is superior to memory for words. To test...
A cognitive psychologist believes that memory for pictures is superior to memory for words. To test this hypothesis, the psychologist performs an experiment in which students from an introductory psychology class are used as participants. Ten randomly selected students view 30 slides with nouns printed on them, and another group of eight randomly selected students views slides with pictures of the same nouns. Each slide is presented for 4 seconds. After viewing the slides, participants are given a recall test,...
The following problems are related to PIC18F46K22 data memory: (a) What is the data memory space...
The following problems are related to PIC18F46K22 data memory: (a) What is the data memory space and actual implemented size? (b) What does direct addressing mean? (c) What does indirect addressing mean? (d) What is the Access Bank used for? (e) What is the address range for Bank 6? (f) What is the purpose of the registers FSR0, FSR1, FSR2 for?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT