CS61C
C
printf:%smeans print a string%dmeans print a decimal number%Xmeans print a hexadecimal number
^bitwise XOR- 取反最低位
X^1注意不是~X - C Macro: "Find and replace"
typedef A Bdef B as Aint32_tmeans 32 bits, and 4 bytes- Endianness and Alignment
- Endianness: little endian
- Alignment
- Address Space
- passing pointers caller to callee is ok, but never callee to caller.
realloc(void* ptr, size_t size)returns new address of block.(in heap)realloc(NULL, size);behaves like mallocrealloc(ptr,0);behaves like free
**
//Safer
TYPE *tmp = realloc(ptr, NEW_SIZE);
if (tmp) { ptr = tmp; }
- valgrind
- Function Pointers

- dereference: access the data/value in the memory.
- Generic Pointers

void *end = (char *) arr + (nelems-1) * nbytes,(char *)means that convert arr from void*(have defined that) to char*- dereference a variable that is not a pointer--C will treat theat variable's underlying bits as if they were a pointer
- 字符串使用双引号而不是单引号。
RISC-V

- R-TYPE

- I-TYPE
I*(shift instructions)

- S-TYPE

- U-TYPE

- B-TYPE

- J-TYPE n

注意
- load 是 load 某寄存器中存储的对应的地址(中的值)类似,而add是处理存储器中存储的值。
jal保存返回值,j不保存返回值。
Compiler,Assembler,Linker,Loader

- Compilation: what it actually means (and discovered it's just the first step in a very long process)
- Assembly: how human-readable parts of assembly code get swapped out for more machine-readable features
- Linking: how different files and libraries make their way into the final product
- Loading: how a system processes our code to run
数电
