首页 > 其他分享 >【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering

时间:2022-12-30 19:01:42浏览次数:54  
标签:CSAPP FF Ordering vectors 二进制 program file bit hello


【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_字符串

一个 w-bit 向量可表示为  

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_操作系统_02

 。用 8-bit 二进制代码表示每个给定的两个无符号整数,也就是一个8-bit 的向量,然后计算这两个集合的交集、并集和对称差。这个集合的元素是 

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_十六进制_03

. 每个元素从左边的位子开始按升序对应。

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_CSAPP_04

 

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_十六进制_05

假设变量 x 和 y 的类型分别为 int 和 short。x 的地址为 0x100,y 的地址为 0x200。x 的四个字节将被存储在内存位置 0x100、0x101、0x102 和 0x103处。y 的两个字节将被存储在内存位置 0x200 和 0x201 处。x 的值是 27066166,y 的值是 41797。如果我们将 x 和 y 分别存储在小端和大端中,那么在给定的内存范围内存储的是什么值?(用十六进制表示)。

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_CSAPP_06

 = 27066166,

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_操作系统_07

 = 19C FF 36

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_sed_08

 = 41797,

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_操作系统_09

 = A3 45

Little endian:36 FF 9C 01  ...  45 A3

Big endian  : 01 9C FF 36  ...  A3 45

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_十六进制_10

a)

1. The preprocessor modifies the original C program according to directives that begin with the # character, and deletes the comments. The result is another C program with the .i suffix.

2. The compiler translates the text file hello.i into the text file hello.s, which contains an assembly-language program. Each statement in an assembly-language program exactly describes one low-level machine-language instruction.

3. The assembler translates hello.s into machine-language instructions, packages them in a form known as a relocatable object program. The result is stored as object file hello.o.

4. A program can call a function resides in a separate precompiled object file. The linker handles this merging, and the executable object file hello is the final output.
 

b) 

High-level programming languages and compilers provide an abstraction for application developers without the need to know internally complex machine-level code

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_字符串_11

a) Registers are a type of computer memory used to quickly accept, store, and transfer data and instructions that are being used immediately by the CPU.

b) The main memory is a temporary storage device that holds both a program and the data it manipulates while the processor is executing the program.

c) The L1 and L2 caches serve as temporary staging areas for information that the processor is likely to need in the near future. So, the processor can read data faster.

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_十六进制_12

将下列的十进制数分别转换成 8-bit 无符号二进制数和对应的十六进制数,如无法转换,记为X。

a) 0        b) 255        c) 256        d) 100

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_字符串_13

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_字符串_14

一个给定的32位二进制代码代表字符串或整数(使用二进制补码)。如果每个字节的十六进制表示法都在下面的转换表中,给定的代码是一个字符串;否则就是一个整数。写下每个二进制代码的字符串或整数。(从左到右) 例子。

a) 45 53 4E 47, ESNG

b) 74 21 33 2e, t!3.

c) FF FF FF D4, -44

d) 00 01 57 A6, 87974

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_操作系统_15

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_操作系统_16

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_sed_17

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_sed_18

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_CSAPP_19

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_sed_20

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_十六进制_21

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_十六进制_22

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_CSAPP_23

【CSAPP】HW1 | 位向量的应用 Application of bit vectors | Adressing and Byte Ordering_字符串_24


标签:CSAPP,FF,Ordering,vectors,二进制,program,file,bit,hello
From: https://blog.51cto.com/u_15153240/5981163

相关文章

  • CSAPP 学习资源与学习计划
    CSAPP(ComputerSystems:AProgrammer’sPerspective)课程学习计划:学习资源:教授上课视频CSAPP课程视频(中英字幕)国人做的笔记电子书国人做的CSAPP重点笔记教授......
  • RCU-1——内核文档翻译——Tree-RCU-Memory-Ordering.rst
    翻译:kernel-5.10\Documentation\RCU\Design\Memory-Ordering\Tree-RCU-Memory-Ordering.rst====================================================TREE_RCU的宽限期内存......
  • CSAPP Cache Lab
    任务A任务主要内容分析编写一个cache仿真程序,使用valgrind的内存跟踪记录作为输入,模拟高速缓存的命中/未命中行为,然后输出总的命中次数,未命中次数和缓存块的替换次数......
  • csapp学习笔记01
    写在开头的话在回到学校之后的几天后,我结束了cmu15418并行系统的学习,怎么说呢?这门课确实让我学到了不少,比如各种并行性的优化,但是我觉得自己还是有些吃力。包括在实习的最......
  • TinyShell(CSAPP实验)
    简介CSAPP实验介绍学生实现他们自己的带有作业控制的UnixShell程序,包括Ctrl+C和Ctrl+Z按键,fg,bg,和jobs命令。这是学生第一次接触并发,并且让他们对Unix的进程控制、......
  • 一个有点咬文嚼字的 sorting 和 ordering
    为什么排序算法的英文是sorting而不是ordering。还真没有怎么研究过这个问题,一般来说数据库中对结果进行排序我们都习惯用OrderBy这个关键字。所有有关算法的排序......
  • X-VECTORS: ROBUST DNN EMBEDDINGS FOR SPEAKER RECOGNITION
    Thissectiondescribesthex-vectorsystem.ItisbasedontheDNNembeddingsin[1]anddescribedingreaterdetailthere.Oursoftwareframeworkhasbeenmade......
  • CSAPPlab报告的图片
       ......
  • 40、使用BBAVectors-Oriented-Object-Detection 进行旋转目标检测,并使用mnn和ncnn进行
    基本思想:需要对身份证进行分割,以满足业务需求,这里还是简单记录一下一开始的实验过程。paper: ​​https://arxiv.org/abs/2008.07043​​​code: ​​https://github.com......
  • RISC- Compiler Reordering- template-compiler分析
    RISC-CompilerReordering-template-compiler分析参考文献链接https://mp.weixin.qq.com/s/0O7BFr6Jh1JTuK7d-icRsAhttps://mp.weixin.qq.com/s/ZLS317bjT3teuzE_ELpg......