CALL & Pthread
CALL & Pthread yiming
Interpretation vs Translation Interpreter: Directly executes a program in the source language For example: python foo.py sh foo.sh Translator: Converts a program from the source language to anequivalent program in another language gcc -FLAG flags foo.c -o foo ./foo javac logism.java –o logism.jar java -jar logism.jar
CALL chain Compiler Assembler Linker Loader
High-Level Language Code -> Assembly Language Code (e.g. MAL) Compiler foo.s High-Level Language Code -> Assembly Language Code (e.g. MAL) Convert marcos … Output may contain pseudo-instructions For example: Move $x $y
Assembler-Proj1.1 foo.o Assembly Language Code (MAL) -> Object Code, information tables(TAL) Totally numbers TAL is some numbers
Assembler-Proj1.1 foo.o Contains 2 passes. first pass Second pass Replace pseudo-instruction To code without labels Second pass Handle branches and labels
Assembler-Proj1.1 pass1 TODO list Skip comments Add labels in symbol table (labels, data) Give addresses Check if invalid inst int pass_one(FILE* input, FILE* output, SymbolTable* symtbl) Note: There are characters. I mean, normal codes No pseudo. The symbol table contains position of labels.
Symbol Table
Relocation Table
Assembler-Proj1.1 pass2 TODO list Check if invalid inst Use label position to generate numbers. Record relocation things to reltbl int pass_two(FILE *input, FILE* output, SymbolTable* symtbl, SymbolTable* reltbl) Note: the pc is with suffix 00 or not
???
After Assembler-Proj1.1 The object file with header Code (number) Data Relocation table Symbol table Debug infos
Linker-Proj1.2 TODO list Object code files, information tables -> Executable code Briefly. Combine multiple object file to a single one Use relocation table and symbol table. Merge text/data segment Create absolute memory addresses Modify & merge symbol and relocation tables Edit Addresses in relocation table Output executable of merged modules(instructions + data + details)
Loader project2 part ./a.out Read instructions allocate space for program Copy data to memory Copy args to stack Init register Execute
Logisim based CPU
Guest lecture: Pthread Yifan