datalab-handout实验

csapp深入了解计算机系统配套datalab-handout实验 修改bits.c的副本,使其通过所有在不违反任何编码准则的情况下在btest中进行测试。 (2)源程序清单或者主要伪代码; ①.bitAnd: 这个函数是将两个数x,y进行与运算。根据以前学的数电的知识,利用摩根定理,/(x&y)=x|y,再次求反可得结果 ②.getByte: 要得到X的第n个字节。只需要简单的把留的字节移到最右端,再与0xff相与即可 ③.logicalShift ... 阅读详情
这是计算机系统2的一个实验作业,花了半天多做完,感觉有几道题挺有趣的,也顺便做一下笔记,方便以后复习或工作时可以查看。
运行环境:ubuntu 16.04。
为了与实验语言一致,我用英文注释了。
/* 
 * 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 
linux按位运算datalab-handout 进入bits.c ,根据bits.c中的具体要求补全以下13个函数: •intbitXor(intx, int y); •inttmin(void); •intisTmax(intx); •ntallOddBits(intx); •intnegate(int x); •intisAsciiDigit(intx); •intconditional(int x, inty, int z) 阅读详情

相关推荐

datalab handout

cmu datalab handout,ics课程的原版提交文件

datalab-handout完成版

datalab-handout完成版,bits.c包含完成课程作业所需要的代码,并且其中备注了实验完成过程中的所有注释

datalab-handout.tar

计算机学习

csapp data lab 满分原创(北大&cmu;) 仅供参考,请勿抄袭

csapp data lab 2016年版本 满分原创(北大&cmu;) 仅供参考,请勿抄袭

slp-week02-datalab_slp_

bits.c practice for System Level Programming

cocos creator接入微信登陆sdk ios篇

cocos creator接入微信登陆sdk ios篇 背景已经在Android篇里面交代过了,有兴趣的朋友可以再看看Android篇 步骤 去微信开放平台下载ios平台所需要的sdk 在“info”标签栏的“URL type“添加“URL scheme”为你所注册的应用程序id 在“info”标签栏的“LSApplicationQueriesSchemes“添加weixin 将SDK文件中...

凤小鹿的博客 6362

Flutter项目在M1/M2 Mac上跑iOS模拟器报错?手把手教你搞定‘arm64架构不兼容’问题

本文详细解析了Flutter项目在M1/M2 Mac上运行iOS模拟器时遇到的‘arm64架构不兼容’问题,提供了多种解决方案,包括排除模拟器的arm64架构、强制使用x86_64架构以及修改插件Podspec文件。帮助开发者快速解决架构兼容性问题,提升开发效率。

weixin_33713707的博客 337

AI全景之第八章第三节:时间序列分析与预测技术

摘要 时间序列分析与预测技术从传统统计模型发展到深度学习方法。传统方法包括ARIMA模型(处理趋势和季节性)、指数平滑(加权平均预测)和状态空间模型(概率框架分解)。机器学习方法通过特征工程和树模型提升非线性建模能力。深度学习方法中,RNN/LSTM处理序列依赖,TCN利用因果卷积,Transformer通过注意力机制捕获长程依赖。当前研究趋势结合神经符号方法和生成模型,以提高预测精度和可解释性。不同方法各具优势,需根据数据特性和预测需求选择。

技术引领业务创新 991

从立创商城到Cadence:手把手教你实现封装格式的精准迁移

本文详细介绍了如何从立创商城获取元器件封装并精准迁移至Cadence Allegro的全流程。通过实战案例MAX31865ATP+T芯片,逐步解析Altium Designer格式转换、Cadence环境配置、封装导入验证等关键步骤,提供常见问题解决方案和效率提升技巧,帮助硬件工程师实现封装格式的高效迁移。

weixin_42519985的博客 216

Qt6安装保姆级教程:从国内镜像下载到配置避坑指南(附清华/中科大源)

本文提供详细的Qt6安装与配置指南,重点介绍如何利用清华大学、中国科学技术大学等国内镜像源解决下载速度慢的问题。内容涵盖在线安装器获取、组件选择策略、环境变量配置以及常见编译与部署问题的排查方法,旨在帮助国内开发者高效、顺畅地完成Qt6开发环境搭建。

weixin_29281915的博客 634

PCL CSF布料模拟算法【2026最新版】

CSF布料模拟地面滤波算法的PCL实现,博客长期更新,本文最近更新时间为:2026年10月26日。

点云侠的博客 3918

SAP FICO 科目余额查询表开发说明书(包括测试样例、程序代码仅作参考,不保证一定可以运行)

SAP FICO 科目余额查询表开发说明书(包括开发源代码、测试样例)

我好像病了的博客 1041

手把手教你学Simulink——基于通信协议与标准的场景实例:卫星通信中的网络安全协议(IPSec)仿真

随着卫星通信在国防、金融、应急指挥、能源管网等关键领域的广泛应用,其安全性已成为系统设计的核心要求。然而,卫星链路具有广播特性、长距离传输、地面站分布广等特点,极易遭受窃听、篡改、重放、中间人攻击等网络威胁。传统的“信任链路层安全”已不足以应对现代网络攻击。为此,国际标准组织(如IETF、ETSI、CCSDS)推荐在卫星通信中部署协议,实现端到端的数据机密性、完整性、身份认证和抗重放保护。本文将手把手教你如何在中构建一个符合标准的仿真系统,涵盖从明文传输到加密隧道的完整安全链路建模。本文完整实现了。

MHD0815的博客 149

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

上一篇: 并行计算-openMP学习笔记(2)
下一篇: hdu4717-(The Moving Points)
blackturtle
博客等级 码龄10年 15粉丝 39原创
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值