《深入理解计算机系统》第3章家庭作业

3.58

long decode2(long x,long y,long z){
	y=y-z;
	x=x*y;
	result = (y<<63)>>63;
	result = result^x;
	return result;
} 

3.60

A:
	%rdi保存x,%esi保存n,%rdx保存mask,%rax保存result
B:
	result = 0;
	mask = 1;
C:
	mask != 0
D:
	mask = (mask << n)
E:
	 result |= (x & mask)
F:
long loop(long x, int n){
    long result = 0;
    long mask;
    
    for (mask = 1; mask != 0; mask = mask << n){
        result |= (x & mask);
    }
    
    return result;
}

3.63

long switch_prob(long x, long n){
    switch(n){
        
    case 60: 
        
    case 62: 
    		 result = x * 8;
             break;
                 
    case 63: 
    		 result = x;
    		 result = result >> 3;
             break;

    case 64: 
    		 result = x;
    		 result = (result << 4) - x;
             x = result;
             
    case 65: x = x * x;
                 
    default: result = x + 0x4b;
    }
    return result;
}

3.69

A. last的偏移量为0x120,即first和a[CNT]占288字节

​ bp+40i+8->%rdx,即first占8字节,数组a元素的偏移量为40字节

​ CNT = (288-8)/40 = 7

B. %rcx-> ap*8 + ap +8,即idx占8字节

a_struct{
	long idx;
	int x[?];
}

3.70

A. e1.p 0

​ e1.y 8

​ e2.x 0

​ e2.next 8

B. 16

C.

up->e1.p = *(*(up->e2.next).e1.p)-*(up->e2.next).e1.y;
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页