x0101 is a twos complement of the number 0x1011 True or False 8 The Carry Flag

X0101 is a twos complement of the number 0x1011 true

This preview shows page 2 - 5 out of 9 pages.

7. 0x0101 is a two’s complement of the number 0x1011. True or False? 8. The Carry Flag (CF) in X86 is primarily used to signify overflows occurring in signed interpretationof the operations. True or False?9. %axregister is the lower 16-bits of %raxregister. True or False? 10. Primary purpose of indirect addressing mode is accesses with pointers. True or False? 2
Image of page 2
Problem 2: C Programming (25 points)1. (5 points) Consider the code fragment in C. Consider that array begins at address 0x1000.int array[100];int* ptr = &array[4];int *ptr2 = &array[102];What will be the memory address pointed by pointerptrandptr2?What is the memory address pointed by pointerptr?What is the memory address pointed by pointerptr2?Assuming you have a precise buffer overflow detector for C. When will the above code experi-ence a buffer overflow?2. (5 points) Consider the code snippet below. What are the necessary conditions for the below code toperform a correct variant of strcpy?char *strcpy(char * d, char *s) {int i, len;len = strlen(s);for (i=0; i<len; i++) {d[i] = s[i];}d[i] = \0;return d;} 3
Image of page 3
3. (15 points) You are given a binary search tree with each node having a left and a right child. If thereare no children in the left or right branch, the respective pointers are NULL. Complete the followingC function to look up a key in the binary search tree. The function returns 1 if the key is found andreturns 0 if the key is not found. Fill in the blanks (....). /* structure for the binary search tree */ struct node{ int value; struct node* left; struct node* right; }; /* initially curr points to the root of the tree */ int lookup(struct node* root, int key){ struct node* curr = root;
Image of page 4
Image of page 5

You've reached the end of your free preview.

Want to read all 9 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture