正在加载图片...
This program is compiled and run on a linux/x86 machine. Fill in the output below. Write"??"if the value cannot be determined from the information provided 0 0 0 0x 0 0x 0x 0x Ox Problem 4:(2*7= 14pts) This problem tests your understanding of labl Fill the following function as you do in Labl ∥ //Determines whether argument y can be added to argument x without overflow ops ∥ Max ops:20 ∥ int addo(int x, int y) Ints=x+y; int over=((Sx) (s^y))>>31 return //Adds two values and if the result(x+y) has a positive overflow it returns l the greatest possible positive value(instead of getting a negative result l If the result has a negative overflow, then it should retum the least Examples: sat Add(0x40000000, 0x40000000)=0x7fffffff satAdd(Ox8000000t=0x8000000 ∥ Legal ops:!~&^|+≤ ∥ Max ops:30 int satAdd(int x, int y) int over=((xs)(ys))>>31 int differ3=s(over 31) return differ3(over <<31); Problem 5:2*5=10pts) the s problem tests your understanding of how for loops in C relate to IA32 machine code. Consider ne following IA32 assembly code for a procedure dog () Page 3 of 7-Page 3 of 7 This program is compiled and run on a Linux/x86 machine. Fill in the output below. Write “??” if the value cannot be determined from the information provided. 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ 0x____ Problem 4: (2*7 = 14pts) This problem tests your understanding of Lab1. Fill the following function as you do in Lab1. // // Determines whether argument y can be added to argument x without overflow. // Legal ops: ! ~ & ^ | + << >> // Max ops: 20 // int addOK(int x, int y) { int s = x + y; int over = ( ( s ^ x ) ( s ^ y ) ) >> 31; return ; } // Adds two values and if the result (x+y) has a positive overflow it returns // the greatest possible positive value (instead of getting a negative result). // If the result has a negative overflow, then it should return the least // possible negative value. // Examples: satAdd(0x40000000,0x40000000) = 0x7fffffff // satAdd(0x80000000,0xffffffff) = 0x80000000 // Legal ops: ! ~ & ^ | + << >> // Max ops: 30 int satAdd(int x, int y) { int s = x ____ y; int over = ( ( x ^ s ) ____ ( y ^ s ) ) >> 31; int differ3 = s ____ ( over ____ 31 ); return differ3 ____ ( over << 31 ); } Problem 5: (2*5 = 10pts) This problem tests your understanding of how for loops in C relate to IA32 machine code. Consider the following IA32 assembly code for a procedure dog():
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有