Compiling, Assembling, Linking and Loading CALL
Interpretation and Translation Interpretation 有一个解释器(是一个程序)
Translation 翻译为低级的语言针对hardware更快操作
Compiler CS164 🤔
这么看来pseudo code确实存在?
Assembler Directives Replacements 把pseudo code翻译成真实的RISC-V指令
Producing real machine code 让.o文件确定终值 ==> object file
简单case:直接用.o文件 Forward reference problem:确定标签位置,然后再用.o文件 PC 相对寻址 Symbol Table and Relocation Table symbol Table label Table 汇编器层面不知道static 之类的东西,所以需要暂时做个记号等待link处理
Object File Format Linker what happen? 4 types of addressing
which instructions must be linked?
J-format: j / jal L-, S-format: there is a gp !
Container box and pointers 见61B 😋
slice 传统python中,slice操作符的语法为[start:stop:step],其中start和stop是切片的起止位置,step是切片的步长(左闭右开)
切片生成新的序列,对原序列的修改不会影响切片(物化view的感觉)
Process value in container aggregate functions sum(container):返回容器中所有元素的和 1 2 3 sum([1, 2, 3, 4, 5]) # 15 sum([1, 2], 9) # 12 sum([[2, 3], [4]], []) # [2, 3, 4] max(container):返回容器中最大的元素 1 max(range(10), key=lambda x: 7-(x-4)*(x-2)) # 3 all(container):如果容器中所有元素都为真,则返回True,否则返回False 1 2 3 all([True, True, True]) # True all([True, False, True]) # False all([x < 5 for x in range(5)]) Strings 注意事实上程序只是字符串 😋 和61B的text写java一个道理
Sequences List 1 2 my_list = [1, 2, 3, 4, 5] getitem(my_list, 2) # Output: 3 加法乘法是 拼接
Container in 1 2 my_list = [1, 2, 3, 4, 5] 5 in my_list # Output: True 1 2 for i in my_list: print(i) unpacking range 1 2 3 range(5) # Output: range(0, 5) range(1, 5) # Output: range(1, 5) range(1, 10, 2) # Output: range(1, 10, 2) 左闭右开
下划线变量命名 1 2 3 _ = 1 # 单个下划线 __ = 2 # 双下划线 __my_var = 3 # 双下划线开头的变量名 List comprehension 1 [x for x in range(5) if x % 2 == 0]