首页 > > 详细

CIS 314讲解、辅导C/C++程序、讲解IA32 register、辅导C/C++设计 解析Java程序|讲解Java程序

Winter ’18 CIS 314 Midterm A Name: SID:
1. [5] What is the decimal value of the byte 0x38, interpreted as an 8-bit unsigned
int Show your work:
2. [5] What is the decimal value the of byte 0x38, interpreted as an 8-bit (signed) int
Show your work:
3. [5] What is the decimal value of the byte 0x83, interpreted as an 8-bit (signed) int?
Show your work:
4. [10] What is the hex value of x >> 4, assuming x is a 32-bit (signed) int with hex
value 0x83838383? Show your work:5. [15] What is the decimal value of 0xC1540000, interpreted as an IEEE-754 signleprecision
float Show your work:
6. [15] Consider the follow C function:
int is NegativeZero(float f);
Implement the above function such that it will return 1 if f == -0.0f, 0 otherwise. Do
this using only bitwise operators (ands, ors, shifts) and integer equality (==); no
floating-point operations, if statements, or loops. Hint: access the bit representation
of f by casting its address to an unsigned-int pointer (similar to assignment 2), then
test the value at this pointer against the expected IEEE-754 bit representation for
-0.0 as hex. Comment your code:7. [20] Consider the following IA32 code, resulting from compiling a function int f(int
x, int y):
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
movl 12(%ebp), %ecx
leal 10(%ecx,%eax,8), %eax
popl %ebp
retl
a. (15) Convert the above code to C. Comment your code:
b. (5) What is returned by f(1, 2)? Show your work:8. [25] Consider the following C code:
int popCount(unsigned int x) {
int result = 0;
do {
result += x & 0x1;
x >>= 1;
} while (x);
return result;
}
a. (10) The above code counts the number of 1s in the bit representation of x.
Rewrite the code (in C) to use a label and goto statement rather than a loop.
Comment your code:
b. (15) Convert your C code from part A above into IA32, ensuring that register use
is correct with respect to the IA32 register conventions. Comment your code:

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!