Arm In-line Assembly

__asm

Example[1]:

#include <stdio.h>

int add(int i, int j)
{
  int res = 0;
  __asm ("ADD %[result], %[input_i], %[input_j]"
    : [result] "=r" (res)
    : [input_i] "r" (i), [input_j] "r" (j)
  );
  return res;
}

int main(void)
{
  int a = 1;
  int b = 2;
  int c = 0;

  c = add(a,b);

  printf("Result of %d + %d = %d\n", a, b, c);
}

我们仔细研究上述的例子,可以看到,其内嵌了一条 ADD 指令,其语法如下所示:

__asm [volatile] (code); /* Basic inline assembly syntax */

其中的 code 就是我们需要内嵌的汇编代码,其中 [volatile] 是可选的,后续我们再对此进行说明。

如果将 code 展开的话,如下所示:

/* Extended inline assembly syntax */ 
__asm [volatile] (code_template 
       : output_operand_list 
      [: input_operand_list 
      [: clobbered_register_list]] 
  );

我们总共有 3 个 ”:“, 每一个后面都有不同的含义,下面对其进行具体说明。(注意 [] 符号包含住表示的是这个参数是可选的)


Someone大约 3 分钟Arm
Virtual Memory

Abstract

本文主要讲述和理解虚拟内存(后文简称 VM, VA 等)的概念,行文可能较为跳跃,需要特别注意。

Virtual Memory

Abstract

Virtual memory is a technique used by operating systems to enable programs to use more memory than is physically available in the system. When a program accesses memory, the address it uses is a virtual address, which is translated by the hardware into a physical address that corresponds to a location in physical memory. This translation process can be slow, especially if it has to be performed every time the program accesses memory.


Someone大约 8 分钟Arm
Cache

Abstract

Introduction

哲学含义

程序员总希望存储是无限的,我们通过一系列的技术手段让程序员产生这种错觉。

本文主要研究存储层次结构中的 cache 环节,本文的行文构成包含如下:

  1. 介绍空间局部性原理和时间局部性原理
  2. 简单介绍 cache 的基本概念,包括 cache line 各个字段的解析
  3. 介绍 cache 的 hit, miss 发生的原因、造成的影响以及可能的解决方案;包括两个重要的算法和通用的处理 cache miss 的方法
  4. 介绍 cache 的几种映射方式和置换策略
  5. 写 cache 相关的技术点,Write miss 相关介绍
  6. cache 一致性监听协议 MESI(x)
  7. 其他的相关知识

Someone大约 25 分钟Arm
Pipeline

Abstract

本文主要研究流水线技术在计算机体系结构中的应用。流水线技术分为两个大的部分,本部分统一研究流水线的基础知识部分,总体而言可以分为以下几类:

  1. data path implications, hazards and examining the performance of pipelines.
  2. interaction between pipelining and various aspects of instruction set design
  3. etc..

What is pipeline?


Someone大约 15 分钟Arm