Question

If i have an array that i know is in address 0x40001008, given the below code...

If i have an array that i know is in address 0x40001008, given the below code what are the values of arrayptr and x?

unsigned short array[5] = {0x123, 0x456, 0x789, 0xabc, 0xdef};

unsigned char *arrayptr = (unsigned char *)array +3;

unsigned short x = *arrayptr;

Homework Answers

Answer #1

Base address of the array called array is 0x40001008 or 40001008H given in Hexadecimal number system.

1.) arrayptr is a character pointer which is assigned the value = (unsigned char *)array + 3 , the array pointer is typecasted into a character pointer i.e. (unsigned char *)array and adding 3 to it will increase it by 3 byte as char occupies 3 byte so the value of arrayptr = 0x4000100B using the calculation given below.

0x40001008
+ 3
Ans 0x4000100B

since 8+3 = 11 in decimal system and 11 = B in hexadecimal system.

2.) x is assigned the value at adress location 0x4000100B and at the address 0x4000100A the value 0x456 is present i.e. (0100 0101 0110) in binary and (1110) in decimal , so the value of x is 4.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In Java is there a way I can put a value in a linkList = array[...
In Java is there a way I can put a value in a linkList = array[ ] string (I don't know how to word it here what I have so far with my code) * Example object 51 I want to equal Array [0]; // Project code below public String getCardRank() { String values[] = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"}; return "RRR"; } // this part is in another .java file private...
Complete the code below that aims to convert the String "input" to a static array of...
Complete the code below that aims to convert the String "input" to a static array of char named "array". You are NOT allowed to use String's toCharArray method! java String input = "Have you voted yet?"; char array[] =
Consider the C code below which reverses the elements in the array A in place. Both...
Consider the C code below which reverses the elements in the array A in place. Both array indexing and pointer versions are given. Assume that A holds doubleword integers and that size is the number of elements in the array. Translate to RISC-V using as few instructions as possible. For your RISC-V code, assume the base address of A is initially in x10 and that the number of elements in the array (i.e., size) is initially in x11. long long...
2.  Suppose we have 3 arrays A, B, and C, array A’s base address is in $S3,...
2.  Suppose we have 3 arrays A, B, and C, array A’s base address is in $S3, B’s base address is in $S4, C’s base address is in $S5. You can only use two temporal registers $t0 and $t1. Convert the following code into MIPS assembly language code. Suppose every array element occupies 1 word in MIPS (32 bits). A[21] = B[0] + C[16];
Complete the following function (detailed instructions are given below the code): private static int predecessor(int array[],...
Complete the following function (detailed instructions are given below the code): private static int predecessor(int array[], int arrayLen, int key) { // Complete this function. } Given a set of numbers, the predecessor of a number x is the highest number in the set that is less than or equal to x. Thus, if I have the set {6; 9; 10; 13; 22; 31; 34; 88}, then the predecessor of 31 is 31 itself, whereas the predecessor of 30 is...
IN JAVA PLEASE write code to MERGESORT an array of user inputted OBJECTS you have two...
IN JAVA PLEASE write code to MERGESORT an array of user inputted OBJECTS you have two different classes in the program being made as objects in the main (Bunny class and Dog Class). ask the user "what kind of animal would you like to sort?" user chooses the type of animal (bunny or dog), then you ask the user how big would you like the array of animals to be (maximum array size = 20)? and then you ask what...
Fill in the code for the function below called containsAvgValue. It takes as input a float...
Fill in the code for the function below called containsAvgValue. It takes as input a float array of any length and returns 1 if the array happens to contain a value that equals the average of all the values in the array or 0 otherwise. For example, when give the array [2.0, 2.0] it should return 1 since the average value is 2.0 and the array contains that value. To help you, I’ve included a function that computes the average...
We are given an array A of size n containing n positive and negative integers (the...
We are given an array A of size n containing n positive and negative integers (the array is indexed starting from 0). Our goal is to find two indices i and j such that 0 ≤ i ≤ j ≤ n and Pk=j k=i A[k] is maximized. Input sequence: [2, -4, 1, 9, -6, 7, -3] Output: [1, 9, -6, 7] or i = 2 and j = 5 Input sequence: [1, 2, 3, 4, 5, 6, -3] Output: [1,...
Given an array of integers return the sum of the values stored in the first and...
Given an array of integers return the sum of the values stored in the first and last index of the array. The array will have at least 2 elements in it --------------------------------------- public class Class1 { public static int endSum(int[] values) {     //Enter code here } }
Given the array below, provide the JS code to loop through the array and print each...
Given the array below, provide the JS code to loop through the array and print each item to the console prepended by "Harry Potter and the " var books = [ "Philosopher's Stone (1997)", "Chamber of Secrets (1998)", "Prisoner of Azkaban (1999)", "Goblet of Fire (2000)", "Order of the Phoenix (2003)", "Half-Blood Prince (2005)", "Deathly Hallows (2007)" ] The console output should be: Harry Potter and the Philosopher's Stone (1997) Harry Potter and the Chamber of Secrets (1998) Harry Potter...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT