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

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

一个 w-bit 向量可表示为   。用 8-bit 二进制代码表示每个给定的两个无符号整数,也就是一个8-bit 的向量,然后计算这两个集合的交集、并集和对称差。这个集合的元素是 . 每个元素从左边的位子开始按升序对应。

a)   Let 28 = 00011110 is

     Let 64 = 01000000 is

     Then, translated by bit vector, we can get       ,so that

           (intersection)

            (union)

             (symmetric difference)

b)  Same Way,  Let 63 = 00111111 is

     Let 112 = 01110000 is

     Then,       ,so that

          (intersection)

           (union)

          (symmetric difference)

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

= 27066166, = 19C FF 36

= 41797, = A3 45

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

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

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

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.

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

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

a)  00000000, 00

b)  255 = , 11111111 , FF

c)  256 = ,  X

d)  100 = ,  01100100 , 64

一个给定的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

a)   211 + 240 = 451,384 + 247 = 631

b)for unsigned integer representation,

two's complement encoding integer representation,


相关文章
|
6月前
|
iOS开发
Xcode报错“compact unwind compressed function offset doesn‘t fit in 24 bits
Xcode报错“compact unwind compressed function offset doesn‘t fit in 24 bits
63 1
|
机器学习/深度学习 自然语言处理 TensorFlow
Long Short-Term Memory,简称 LSTM
长短期记忆(Long Short-Term Memory,简称 LSTM)是一种特殊的循环神经网络(RNN)结构,用于处理序列数据,如语音识别、自然语言处理、视频分析等任务。LSTM 网络的主要目的是解决传统 RNN 在训练过程中遇到的梯度消失和梯度爆炸问题,从而更好地捕捉序列数据中的长期依赖关系。
122 4
|
人工智能 编解码 自动驾驶
YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors
YOLOv7在5 FPS到160 FPS的范围内,在速度和精度方面都超过了所有已知的物体检测器,在GPU V100上以30 FPS或更高的速度在所有已知的实时物体检测器中具有最高的精度56.8% AP。
462 0
|
存储 Linux Windows
ChIP-seq 分析:Call Peak(8)
ChIP-seq 分析:Call Peak(8)
314 0
|
编译器
relocation value does not fit in 26 bits (offset: 0x10, type: 1)
relocation value does not fit in 26 bits (offset: 0x10, type: 1)
199 0
|
机器学习/深度学习
3_Long Short Term Memory (LSTM)
3_Long Short Term Memory (LSTM)
130 0
3_Long Short Term Memory (LSTM)
TypeError: can‘t subtract offset-naive and offset-aware datetimes
TypeError: can‘t subtract offset-naive and offset-aware datetimes
116 0
Data Structures and Algorithms (English) - 7-8 File Transfer(25 分)
Data Structures and Algorithms (English) - 7-8 File Transfer(25 分)
109 0
Data Structures and Algorithms (English) - 7-12 How Long Does It Take(25 分)
Data Structures and Algorithms (English) - 7-12 How Long Does It Take(25 分)
110 0
Data Structures and Algorithms (English) - 6-2 Two Stacks In One Array(20 分)
Data Structures and Algorithms (English) - 6-2 Two Stacks In One Array(20 分)
140 0