CSAPP lab1 datalab-handout(深入了解计算机系统 实验一)

datalab-handout实验 这是计算机系统2的一个实验作业,花了半天多做完,感觉有几道题挺有趣的,也顺便做一下笔记,方便以后复习或工作时可以查看。 运行环境:ubuntu 16.04。 为了与实验语言一致,我用英文注释了。 /* * CS:APP Data Lab * * <Please put your name and userid here> * * bits.c - Source file with 阅读详情

能看懂的就不写注释了


        /* 
 * CS:APP Data Lab 
 * 
 * <Please put your name and userid here>
 * 
 * bits.c - Source file with your solutions to the Lab.
 *          This is the file you will hand in to your instructor.
 *
 * WARNING: Do not include the <stdio.h> header; it confuses the dlc
 * compiler. You can still use printf for debugging without including
 * <stdio.h>, although you might get a compiler warning. In general,
 * it's not good practice to ignore compiler warnings, but in this
 * case it's OK.  
 */


#if 0
/*
 * Instructions to Students:
 *
 * STEP 1: Read the following instructions carefully.
 */


You will provide your solution to the Data Lab by
editing the collection of functions in this source file.


INTEGER CODING RULES:
 
  Replace the "return" statement in each function with one
  or more lines of C code that implements the function. Your code 
  must conform to the following style:
 
  int Funct(arg1, arg2, ...) {
      /* brief description of how your implementation works */
      int var1 = Expr1;
      ...
      int varM = ExprM;


      varJ = ExprJ;
      ...
      varN = ExprN;
      return ExprR;
  }


  Each "Expr" is an expression using ONLY the following:
  1. Integer constants 0 through 255 (0xFF), inclusive. You are
      not allowed to use big constants such as 0xffffffff.
  2. Function arguments and local variables (no global variables).
  3. Unary integer operations ! ~
  4. Binary integer operations & ^ | + << >>
    
  Some of the problems restrict the set of allowed operators even further.
  Each "Expr" may consist of multiple operators. You are not restricted to
  one operator per line.


  You are expressly forbidden to:
  1. Use any control constructs such as if, do, while, for, switch, etc.
  2. Define or use any macros.
  3. Define any additional functions in this file.
  4. Call any functions.
  5. Use any other operations, such as &&, ||, -, or ?:
  6. Use any form of casting.
  7. Use any data type other than int.  This implies that you
     cannot use arrays, structs, or unions.


 
  You may assume that your machine:
  1. Uses 2s complement, 32-bit representations of integers.
  2. Performs right shifts arithmetically.
  3. Has unpredictable behavior when shifting an integer by more
     than the word size.


EXAMPLES OF ACCEPTABLE CODING STYLE:
  /*
   * pow2plus1 - returns 2^x + 1, where 0 <= x <= 31
   */
  int pow2plus1(int x) {
     /* exploit ability of shifts to compute powers of 2 */
     return (1 << x) + 1;
  }


  /*
   * pow2plus4 - returns 2^x + 4, where 0 <= x <= 31
   */
  int pow2plus4(int x) {
     /* exploit ability of shifts to compute powers of 2 */
     int result = (1 << x);
     result += 4;
     return result;
  }


FLOATING POINT CODING RULES


For the problems that require you to implent floating-point operations,
the coding rules are less strict.  You are allowed to use looping and
conditional control.  You are allowed to use both ints and unsigneds.
You can use arbitrary integer and unsigned constants.


You are expressly forbidden to:
  1. Define or use any macros.
  2. Define any additional functions in this file.
  3. Call any functions.
  4. Use any form of casting.
  5. Use any data type other than int or unsigned.  This means that you
     cannot use arrays, structs, or unions.
  6. Use any floating point data types, operations, or .




NOTES:
  1. Use the dlc (data lab checker) compiler (described in the handout) to 
     check the legality of your solutions.
  2. Each function has a maximum number of operators (! ~ & ^ | + << >>)
     that you are allowed to use for your implementation of the function. 
     The max operator count is checked by dlc. Note that '=' is not 
     counted; you may use as many of these as you want without penalty.
  3. Use the btest test harness to check your function for correctness.
  4. Use the BDD checker to formally verify your functions
  5. The maximum number of ops for each function is given in the
     header comment for each function. If there are any inconsistencies 
     between the maximum ops in the writeup and in this file, consider
     this file the authoritative sourc.


/*
 * STEP 2: Modify the following functions according the coding rules.
 * 
 *   IMPORTANT. TO AVOID GRADING SURPRISES:
 *   1. Use the dlc compiler to check that your solutions conform
 *      to the coding rules.
 *   2. Use the BDD checker to formally verify that your solutions produce 
 *      the correct answers.
 */




#endif
/* 
 * bitAnd - x&y using only ~ and | 
 *   Example: bitAnd(6, 5) = 4
 *   Legal ops: ~ 
 *   Max ops: 8
 *   Rating: 1
 */
int bitAnd(int x, int y) {
	int ret = ~(~x | ~y);
  return ret;
}
/* 
 * getByte - Extract byte n from word x
 *   Bytes numbered from 0 (LSB) to 3 (MSB)
 *   Examples: getByte(0x12345678,1) = 0x56
 *   Legal ops: ! ~ & ^ | + << >>
 *   Max ops: 6
 *   Rating: 2
 */
int getByte(int x, int n) {


	int ret = (x >> (n<<3)) & 0XFF;


  return ret;


}
/* 
 * logicalShift - shift x to the right by n, using a logical shift
 *   Can assume that 0 <= n <= 31
 *   Examples: logicalShift(0x87654321,4) = 0x08765432
 *   Legal ops: ! ~ & ^ | + << >>
 *   Max ops: 20
 *   Rating: 3 
 */
int logicalShift(int x, int n) {
	int ret = (x >> n) & (~(((1<<31)>>n)<<1));
  return ret;
}
/*
 * bitCount - returns count of number of 1's in word
 *   Examples: bitCount(5) = 2, bitCount(7) = 3
 *   Legal ops: ! ~ & ^ | + << >>
 *   Max ops: 40
 *   Rating: 4
 */
int bitCount(int x) {
	int tmp = (0x55)|(0x55 << 8);
	int mask1 = tmp | (tmp << 16);
	int mask2 = 0;
	int mask3 = 0;
	int mask4=(0xFF)|(0xFF<<16);         
	int mask5=(0xFF)|(0xFF<<8);
	int result = 0;
	
	tmp = (0x33)|(0x33 << 8);
	mask2 = tmp | (tmp << 16);
	tmp = (0x0F)|(0x0F << 8);
	mask3 = tmp | (tmp << 16);
	 
	
	result=(x&mask1)+((x>>1)&mask1);          
	result=(result&mask2)+((result>>2)&mask2);         
	result=(result+(result>>4))&mask3;         
	result=(result+(result>>8))&mask4;         
	result=(result+(result>>16))&mask5;
	
	return result;
}
/* 
 * bang - Compute !x without using !
 *   Examples: bang(3) = 0, bang(0) = 1
 *   Legal ops: ~ & ^ | + << >>
 *   Max ops: 12
 *   Rating: 4 
 */
int bang(int x) {
  int ret = (~((x | (~x +1)) >> 31)) & 1;
  return ret;
}
/* 
 * tmin - return minimum two's complement integer 
 *   Legal ops: ! ~ & ^ | + << >>
 *   Max ops: 4
 *   Rating: 1
 */
int tmin(void) {
  return (1<<31);
}
/* 
 * fitsBits - return 1 if x can be represented as an 
 *  n-bit, two's complement integer.
 *   1 <= n <= 32
 *   Examples: fitsBits(5,3) = 0, fitsBits(-4,3) = 1
 *   Legal ops: ! ~ & ^ | + << >>
 *   Max ops: 15
 *   Rating: 2
 */
int fitsBits(int x, int n) {
	int shift_cnt = ~n +33;
  return !(x^((x<<shift_cnt)>>shift_cnt));
}
/* 
 * divpwr2 - Compute x/(2^n), for 0 <= n <= 30
 *  Round toward zero
 *   Examples: divpwr2(15,1) = 7, divpwr2(-33,4) = -2
 *   Legal ops: ! ~ & ^ | + << >>
 *   Max ops: 15
 *   Rating: 2
 */
int divpwr2(int x, int n) {
		int mask = (~0)+(1<<n);
		
		int bias = (x>>31)&mask;
		
    return (x+bias)>>n;
}
/* 
 * negate - return -x 
 *   Example: negate(1) = -1.
 *   Legal ops: ! ~ & ^ | + << >>
 *   Max ops: 5
 *   Rating: 2
 */
int negate(int x) {
  return (~x) + 1;
}
/* 
 * isPositive - return 1 if x > 0, return 0 otherwise 
 *   Example: isPositive(-1) = 0.
 *   Legal ops: ! ~ & ^ | + << >>
 *   Max ops: 8
 *   Rating: 3
 */
int isPositive(int x) {
	
  return (!((x>>31) & 0x01)) & (!!(x));
}
/* 
 * isLessOrEqual - if x <= y  then return 1, else return 0 
 *   Example: isLessOrEqual(4,5) = 1.
 *   Legal ops: ! ~ & ^ | + << >>
 *   Max ops: 24
 *   Rating: 3
 */
int isLessOrEqual(int x, int y) {
	int signx = x>>31;
	int signy = y>>31;
	
	int signEqual = (!(signx ^signy)) & ((x+(~y))>>31);
	int signDiffer=signx&(!signy); 
  return signEqual|signDiffer;
}
/*
 * ilog2 - return floor(log base 2 of x), where x > 0
 *   Example: ilog2(16) = 4
 *   Legal ops: ! ~ & ^ | + << >>
 *   Max ops: 90
 *   Rating: 4
 */
int ilog2(int x) {
  int bitsNumber=0;          
  bitsNumber=(!!(x>>16))<<4;          
  bitsNumber=bitsNumber+((!!(x>>(bitsNumber+8)))<<3);         
  bitsNumber=bitsNumber+((!!(x>>(bitsNumber+4)))<<2);         
  bitsNumber=bitsNumber+((!!(x>>(bitsNumber+2)))<<1);         
  bitsNumber=bitsNumber+(!!(x>>(bitsNumber+1)));         
  bitsNumber=bitsNumber+(!!bitsNumber)+(~0)+(!(1^x));         
  return bitsNumber;
}
/* 
 * float_neg - Return bit-level equivalent of expression -f for
 *   floating point argument f.
 *   Both the argument and result are passed as unsigned int's, but
 *   they are to be interpreted as the bit-level representations of
 *   single-precision floating point values.
 *   When argument is NaN, return argument.
 *   Legal ops: Any integer/unsigned operations incl. ||, &&. also if, while
 *   Max ops: 10
 *   Rating: 2
 */
unsigned float_neg(unsigned uf) {
	
	unsigned res = 0;
	unsigned tmp = 0;
	
	tmp = uf & 0x7fffffff;
	res = uf ^ 0x80000000;
	
	if(tmp > 0x7f800000)
		res = uf;
		
  return res;
}
/* 
 * float_i2f - Return bit-level equivalent of expression (float) x
 *   Result is returned as unsigned int, but
 *   it is to be interpreted as the bit-level representation of a
 *   single-precision floating point values.
 *   Legal ops: Any integer/unsigned operations incl. ||, &&. also if, while
 *   Max ops: 30
 *   Rating: 4
 */
unsigned float_i2f(int x) {
  
    int sign=x>>31&1;//获取符号位(1位)
    int i;
    int exponent; //指数域(8位)
    int fraction; //小数域
    int delta;//偏差(用于舍入)
    int fraction_mask;//小数域的掩码(23位)
    if(x==0)//如果为0就直接返回
        return x;
    else if(x==0x80000000)//如果为TMin,解释为-(2^31),对应float就是(1)x1.0x2^31,所以S=1,M=1,E=31,指数域=31+127=158
        exponent=158;
    else{
        if (sign)//通过前面的操作已经确定了符号,先把int的绝对值获取,之后利用浮点数的计算公式即可计算出float的值,现在要获取绝对值存入内存中
            x = -x;
        
        i = 30;//最高位是符号位,次高位是有效数字的起始位
        while ( !(x >> i) )//从左往右查找有效数字第一个不为零的位,对应的位置就是最终的i(这里的位置从0开始标号)
            i--;
        //printf("%x %d\n",x,i);
        exponent = i + 127;//数值的最高位已经找到是第i位(有效数据共有i+1位),又因为int类型不可能是非规格数据的范围(为0的情况在前面已排除),所以小数域就是d第i为后面的位向量(小数域一共有i个位),故阶码E=i(小数部分x2的E次方),指数域等于i+127;
        x = x << (31 - i);//清除有效数据前面的所有0,包括符号位,得到有效数据开头的数据
        fraction_mask = 0x7fffff;//设置23位的小数域掩码
        fraction = fraction_mask & (x >> 8);//虽然按照浮点数格式,最前面的9个位不加入小数位,按道理应该右移9位,
        																		//但是由于int类型的参数不可能是非规格数,所以最前面的一个有效数据也被舍弃(默认M=1+f),
        																		//当向右移动8位,舍弃了有效数据的低8位,再和掩码处理以后,一共舍弃了9位
        																		//除了低八位还包括有效数据的最高位,类比二进制小数中小数点左边的那一位数字,在float存储的时候,小数点左边数字不存入内存
        																		//者9个位用来存储符号位+指数域
        x = x & 0xff;//由于右移8位,舍弃了有效数据第八位,现在获取低八位用于舍入操作
        delta = x > 128 || ((x == 128) && (fraction & 1));//如果低八位超过八位二进制能表示的无符号数的一半,
        																									//要在小数域+1,普通的四舍五入思想
        																									//如果低八位刚好等于八位二进制能表示的无符号数的一半,而且小数域目前最后一位是1,
        																									//根据向偶数舍入的模式,也要在小数域+1,向上舍入的思想,
        																									//如果低八位刚好等于八位二进制能表示的无符号数的一半,如果小数域目前最后一位是0,则向下舍入,不加1
        																									//如果低八位刚好小于八位二进制能表示的无符号数的一半,直接丢弃,不加1,普通的四舍五入思想
        fraction += delta;//进行舍入
        if(fraction >> 23) {//如果舍入过后,小数域多余23位,则只取低23位,高位舍弃,但是阶码E要加1,所以指数域也就要加1
            fraction &= fraction_mask;
            exponent += 1;
        }
    }
    return (sign<<31)|(exponent<<23)|fraction;//符号位最高位(31),指数域(30--23),小数域(22-0)
}
/* 
 * float_twice - Return bit-level equivalent of expression 2*f for
 *   floating point argument f.
 *   Both the argument and result are passed as unsigned int's, but
 *   they are to be interpreted as the bit-level representation of
 *   single-precision floating point values.
 *   When argument is NaN, return argument
 *   Legal ops: Any integer/unsigned operations incl. ||, &&. also if, while
 *   Max ops: 30
 *   Rating: 4
 */
unsigned float_twice(unsigned uf) {
  unsigned res = uf;
	
	if((res & 0x7F800000) == 0)
		{
				res = ((res & 0x007FFFFF)<<1) | (res & 0x80000000);	
		}
	else if((res & 0x7F800000) != 0x7F800000)
		{
			  res = res+0x00800000;
		}	
		
  return res;
}



关于统计二进制中1的位数,详细的解释可以引用于stackOverflow

http://stackoverflow.com/questions/3815165/how-to-implement-bitcount-using-only-bitwise-operators


From http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel

unsigned int v; // count bits set in this (32-bit value)
unsigned int c; // store the total here

c = v - ((v >> 1) & 0x55555555);
c = ((c >> 2) & 0x33333333) + (c & 0x33333333);
c = ((c >> 4) + c) & 0x0F0F0F0F;
c = ((c >> 8) + c) & 0x00FF00FF;
c = ((c >> 16) + c) & 0x0000FFFF;

Edit: Admittedly it's a bit optimized which makes it harder to read. It's easier to read as:

c = (v & 0x55555555) + ((v >> 1) & 0x55555555);
c = (c & 0x33333333) + ((c >> 2) & 0x33333333);
c = (c & 0x0F0F0F0F) + ((c >> 4) & 0x0F0F0F0F);
c = (c & 0x00FF00FF) + ((c >> 8) & 0x00FF00FF);
c = (c & 0x0000FFFF) + ((c >> 16)& 0x0000FFFF);

Each step of those five, adds neighbouring bits together in groups of 1, then 2, then 4 etc. The method is based in divide and conquer.

In the first step we add together bits 0 and 1 and put the result in the two bit segment 0-1, add bits 2 and 3 and put the result in the two-bit segment 2-3 etc...

In the second step we add the two-bits 0-1 and 2-3 together and put the result in four-bit 0-3, add together two-bits 4-5 and 6-7 and put the result in four-bit 4-7 etc...

Example:

So if I have number 395 in binary 0000000110001011 (0 0 0 0 0 0 0 1 1 0 0 0 1 0 1 1)
After the first step I have:      0000000101000110 (0+0 0+0 0+0 0+1 1+0 0+0 1+0 1+1) = 00 00 00 01 01 00 01 10
In the second step I have:        0000000100010011 ( 00+00   00+01   01+00   01+10 ) = 0000 0001 0001 0011
In the fourth step I have:        0000000100000100 (   0000+0001       0001+0011   ) = 00000001 00000100
In the last step I have:          0000000000000101 (       00000001+00000100       )

which is equal to 5, which is the correct result


再附上几个参考资料

http://wdxtub.com/2016/04/16/thick-csapp-lab-1/


http://wenku.baidu.com/link?url=00k0funtVK1IHYJvtqV-zeywPEWCXf852MxbtxL3WXrFeh7LTUZgBk1ycW9yay5zLC8y20TjSawNKwQ3qSX5Z6XxMlkroBehcRlU3z5i8cS




CSAPP Data Lab 实验指南:位运算与浮点数表示的底层实践 位运算(bitwise operation)是计算机底层编程的核心技术之一,它直接操作数据的二进制位,是理解计算机数据表示和实现高效算法的基石。其原理基于逻辑门电路,通过AND、OR、NOT、XOR以及移位等基本操作,实现对整数的精确控制。掌握位运算对于性能优化、系统编程和嵌入式开发具有重要价值,尤其在处理硬件接口、数据压缩和加密算法等场景中不可或缺。本文聚焦于CMU CSAPP课程经典的Data Lab实验,该实验要求仅使用有限的位运算符完成特定功能,是深入理解补码(Two's Complement)和I 阅读详情

相关推荐

CSAPP:Lab的Datalab中bitCount的思路

不得不说CSAPP:Lab对于我这样的小白来说的难度还是挺高的,bitCount这题是通过百度才解出来的... 原题: /* * bitCount - returns count of number of 1's in word * Examples: bitCount(5) = 2, bitCount(7) = 3 * Legal ops: ! ~ & ^ | + > *

LinJingchun的博客 6146

CSAPP LAB1 datalab-handout

CSAPP LAB1。完成时间:2022.3.26。仅供参考

Coral__的博客 1349

[语义分割]SPP、空洞卷积与ASPP总结

ASPP全称:Atrous Spatial Pyramid Pooling,中文可以理解为空洞空间卷积池化金字塔或者多孔空间金字塔池化。在这其中,要理解两个概念:一个是SPP,池化金字塔结构或者叫空间金字塔池化层,都是一个东西;另一个是Atrous,空洞卷积,两个加在一起就是ASPP。 首先说一下SPP:Spatial Pyramid Pooling。这个结构出自于论文《Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Re

lipengfei0427的博客 2万+

《深入理解计算机系统》实验一Data Lab

《深入理解计算机系统》实验一Data Lab

达的程序员日记 1万+

金融领域强化学习在多资产类别动态交易执行中的应用

在金融市场中,多资产类别的交易执行面临着诸多挑战,如市场的不确定性、资产间的复杂相关性等。传统的交易策略往往难以适应动态变化的市场环境。本研究的目的在于探索如何运用强化学习技术,实现多资产类别在动态市场环境下的高效交易执行。具体范围涵盖了从强化学习的基本原理到在多资产交易场景中的实际应用,包括核心算法的实现、数学模型的构建以及项目实战等方面。本文首先介绍研究背景,包括目的、预期读者和文档结构。接着阐述核心概念,包括强化学习和多资产类别动态交易执行的原理及其联系。

AI 领航者的博客 637

电商智能客服Agent开发实战:从零到一构建企业级AI助手

电商智能客服Agent是下一代AI应用的核心形态,它不仅能够回答用户问题,还能自主规划任务、调用工具并执行完整工作流程。本文将深入探讨AI Agent的基本概念、技术实现方式及电商场景中的应用,提供完整的开发流程和代码示例,帮助开发者从零开始构建一个功能强大的电商智能客服系统。通过模块化设计、多轮对话记忆管理和工具集成,这个Agent能够处理订单查询、商品推荐、退换货流程等复杂任务,同时具备企业级的安全性和稳定性保障。通过本文的介绍,读者已经掌握了构建电商智能客服Agent的核心技术与实现方法。

m0_64363449的博客 1377

【CSAPP】【答案/解析】《深入理解计算机系统》实验一/datalab-handout实验

【CSAPP】【答案/解析】《深入理解计算机系统》实验一/datalab-handout实验

weixin_72899100的博客 2604

20道SpringSecurity常见面试题汇总(超详细回答 !!!)

本文中,我们将探讨一些与 Spring Security 相关的面试问题。Spring Security 是一款流行的 Java 应用程序安全框架,它提供了一套全面且易于使用的安全解决方案。

小斜同学的博客 3081

深入理解操作系统——datalab-handout

实验目的: 1.替换bits.c中各个函数中的return,格式要求如下所示: int Funct(arg1, arg2, …) { /* brief description of how your implementation works */ int var1 = Expr1; … int varM = ExprM; varJ = ExprJ; ... varN = ExprN; ...

君陌的博客 7461

保姆级避坑指南:在openEuler 22.03 LTS上用kubeadm 1.32.2部署K8s集群(含阿里云镜像加速)

本文提供在openEuler 22.03 LTS上使用kubeadm 1.32.2部署Kubernetes集群的详细指南,涵盖系统准备、容器运行时适配、kubeadm配置及集群初始化等关键步骤。特别针对openEuler系统的特殊性,解决软件源配置、cri-dockerd编译安装、阿里云镜像加速等常见问题,帮助用户高效完成K8s集群部署。

weixin_28312391的博客 276

ThingsBoard3.9.1规则引擎方式发送钉钉通知消息

thingsboard3.9.1/4.0规则链方式发送钉钉通知消息。

hssjf的专栏 535

《深入理解计算机系统》Lab1:Data Lab(一)

第1关:bitAnd 任务描述 本关任务:补充函数bitAnd(),只用~、|实现x&y,将结果return返回。 操作符限制:~、| 操作符使用数量限制:8 测试说明 平台会对你编写的代码进行测试: 测试输入:65 预期输出:4 int bitAnd(int x, int y) { /********* Begin *********/ int ret; x=~x; y=~y; ret =x|y; ret=~ret; return ret; /*******

drizzle2333的博客 7461

2024-江苏科技大学-模拟-动态接触角,模拟液滴撞击,comsol软件模拟。

相反,其对液滴粘度和平衡接触角的变化基本不敏感。重力势能的影响显著受过程参数调节,随着液滴直径和密度的增加而增加,而随着初始液滴速度和表面张力系数的增加而减小。通过考虑形状因子和粘度修正因子,可以准确定义表面能和粘性耗散能,使得所提出的半经验修正勺状模型表现出良好的性能,在所有65个研究案例中,液滴最大铺展长度因子(βmax)和中心厚度(h)的相对误差基本分别落在5%和10%的区间内。重力势能的影响受过程参数显著调节,随液滴直径和密度的增大而增大,随液滴初始速度和表面张力系数的增大而减小。

qq_15963745的博客 516

CSAPP DataLab实验全面解析(包含代码和具体分析)

该实验是《深入理解计算机系统》课程的核心实践环节,要求通过位级操作实现13个函数,深入理解整数和浮点数的二进制表示。

小李独爱秋的博客 2844

华为OD机考2025B卷 - 报文响应时间(Java & Python& JS & C++ & C )

华为OD机考2025B卷 - 报文响应时间

算法大师! 8087

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

计算机系统实验LAB2实验代码及详细实验报告:datalab-handout.tar:填写bits.c文件中尚未完成的各个函数的内容

题目来源:深入理解计算机系统实验二 实验题目:LAB2-datalab 实验目的:通过此次实验,进一步熟悉整型及浮点数的位表达形式,实现常用二进制运算的常用方法。 ReadmeFirst: 本次文件夹包括本次课程实验LAB2的内容,内含2个文件:datalab-handout.tar以及ReadmeFirst.txt。 本次实验内容经过在ubuntu12.04环境中测试,均可运行通...

乔卿的博客 1万+

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

datalab-handout实验1的准备工作

这个第一个lab准备工作写在前面,这个关于如何开始编写程序,测试程序的正确性的。 !!!最重要有一台linux系统的电脑,虚拟机也可以。 需要从这个网址下载实验文件。http://csapp.cs.cmu.edu/3e/labs.html ,找到第一个实验,Data Lab 然后点击Self Study Handout,会有下载一个解压包。 解压出来的文件有bits.c,btest等文件,然后b...

Greatljc的博客 1330

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

深入理解计算机系统(CSAPP)实验二 datalab-handout

实验的目的是 填写 bits.c里面的函数,使其按照规定的要求(比如只能使用有限且规定的操作符和数据类型,不能使用控制语句等等)实现函数的功能。 同时 dlc文件是用来检测 bits.c 里面的函数是否 是按照要求编写的,有没有使用非法的数据类型等。 使用方法:./dlc bits.c 检测成功后,使用 btest 测试 每一个函数功能方面是否正确无误。使用方法:./btest,如...

aocang4831的博客 1427

CSAPP lab1 datalab-handout

这是一个关于机器级的整数、浮点数表示和位运算的实验。要求用给定的操作符、尽可能少的操作数去实现对应的函数功能。 完整的实验包:链接: https://pan.baidu.com/s/1xUBi3XDlidPQFNexbjXoLw 密码: 2333 以下是全部函数的代码: 1 /*****************************计算log2(x)向下取整*******...

dianshu1593的博客 595

如何阅读《深入理解计算机系统》这本书? (转载)

转载自:https://www.zhihu.com/question/20402534#answer-43539853 学CS的话,不太建议看书。凡是学一门课,看优秀的公开课视频以及写编程作业是最有效率的方法。对CSAPP也不例外。这本书对应的课是CMU 15213/15513。课程网站的官方地址是15-213/18-218/15-513: Introduction to Computer Sys...

abc 4424

CSAPP Data Lab环境搭建与位运算实战:从虚拟机配置到函数实现

计算机系统基础课程中,位级运算与数据表示是理解计算机底层工作原理的核心。通过位操作符(如与、或、非、异或、移位)直接操作二进制数据,可以深入掌握整数补码、浮点数IEEE 754标准等关键概念。这种底层技术能力对于优化算法、理解硬件交互以及进行系统级编程具有重要价值,常见于编译器开发、嵌入式系统和性能敏感型应用场景。本文聚焦于CSAPP Data Lab实验,详细讲解如何在Linux虚拟机中搭建实验环境,并逐步实现位运算函数,其中涉及**虚拟机配置**与**位操作**等关键热词,帮助读者在标准化环境中完成从环

weixin_33747129的博客 433

[深入理解计算机系统]lab作业地址

http://csapp.cs.cmu.edu/3e/labs.html http://www.hh-yzm.com/ https://www.cnblogs.com/HacTF/p/8029197.html https://github.com/Ethan-Yan27/CSAPP-Labs 1. datalab https://blog.csdn.net/tzh476/ar...

Lord_sh的博客 926

CSAPP-datalab

CSAPP-datalab

Wall_e_47的博客 844

深入理解计算机系统——datalab实验

实验目的: 完善bits.c里的各个函数,实现其功能,并通过btest的测试 实验说明: 实验的目标是修改bits.c的副本,以便它通过所有在btest中进行测试而不违反任何编码准则。 1、使用dlc编译器(./dlc)自动检查代码是否符合标准。 命令:unix> ./dlc bits.c 说明:如果代码没有问题,dlc会直接返回,否则,它会打印标记问题的消息。 命令:unix> ./...

forest_one的博客 1万+

<csapp> data lab (《深入理解计算机系统》lab1)

po主是在读大学生一枚,最近在

Stone 9753
上一篇: 求二进制数中1的个数
下一篇: 03字符串操作和一级指针内存模型
小帅比simon
博客等级 码龄15年 213粉丝 329原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值