[video member=pervognsen stream_platform=twitch project=bitwise title="RISC-V Static Assembler, Part 3" vod_platform=youtube id=CRAMT1QRRjo annotator=Miblo]
[0:00][Recap and set the stage for the day][:speech]
[0:40][Determine that distinguishing symbols at the lexical level was a design fault, and to rectify this][:asm :parsing :speech]
[3:20][Replace str_range_to_sym() and the notion of multiple symbol kinds at the lexical level with str_intern_range()][:asm :parsing]
[6:06][Simplify parse_line() to call parse_name() and semantically integrate the lexer and parser into the assembler][:asm :parsing]
[13:17][:Run it to see that it looks reasonable][:asm :parsing]
[13:37][Review newline handling in next_token()][:asm :parsing :speech]
[15:22][Setup to create a symbol table][:asm :parsing]
[17:35][Enable parse_line() to distinguish xregs and instructions[ref
    author="Andrew Waterman and Krste Asanović"
    title="The RISC-V Instruction Set Manual - Volume 1: User-Level ISA"
    url=https://github.com/riscv/riscv-isa-manual/blob/master/release/riscv-spec-v2.2.pdf]][:asm :parsing]
[25:17][Introduce def_instr() and its accompanying instr_defs instruction table][:asm :parsing]
[32:54][Step in to parse_line() to see what's going on][:asm :parsing :run]
[33:06][Introduce def_instrs() for init_assembler() to call][:asm :parsing]
[34:33][:Run it to see that it found our "add" instruction][:asm :parsing]
[34:46][Fill in the instr_defs table[ref
    author="Andrew Waterman and Krste Asanović"
    title="The RISC-V Instruction Set Manual - Volume 1: User-Level ISA"
    url=https://github.com/riscv/riscv-isa-manual/blob/master/release/riscv-spec-v2.2.pdf]][:asm :parsing]
[43:59][Introduce parse_instr() to handle registers and immediates, lofting out the interning part of def_sym() to add_sym()][:asm :parsing]
[49:46][:Run it to see that the old stuff does still work][:asm :parsing]
[50:13][Introduce def_regs()][:asm :parsing]
[52:55][Step in to parse_line() to see what's going on][:asm :parsing :run]
[53:44][Make init_assembler() call def_regs()][:asm :parsing]
[54:01][:Run it to see that it works][:asm :parsing]
[54:13][Fix parse_xreg() to print the error-causing token, rather than the next token][:asm :"error handling" :parsing]
[54:39][Test our :"error handling"][:asm :parsing :run]
[55:07][A few words on sections in executables][:asm :"code generation" :speech]
[57:49][Augment the Assembler struct with section-like data and introduce asm_bytes() to emit our code][:asm :"code generation"]
[1:07:09][Introduce parse_lines() and add some :emulation of our :asm emission to asm_test()][:"code generation" :parsing]
[1:08:48][Introduce parse_imm() for parse_instr() to call, and emit immediates][:asm :"code generation" :parsing]
[1:11:54][Test our assembler on an addi instruction][:asm :"code generation" :parsing]
[1:12:17][Step through parse_instr() to see how it handles our immediate][:asm :"code generation" :parsing :run]
[1:14:05][Fix asm_bytes() to update the buffer size][:memory]
[1:14:49][:Run it to see that it worked][:asm :"code generation" :parsing :run]
[1:15:09][Handling labels in a multi-pass assembler][:asm :parsing :speech]
[1:19:35][Implement support for back-referenced load labels in parse_instr()][:asm :"code generation" :parsing]
[1:30:18][Introduce init_cmds() and related functions and structs for defining data types][:asm :parsing]
[1:40:23][Test the assembler on our "val" label][:asm :"code generation" :parsing]
[1:40:41][:Run it to see that it worked][:asm :"code generation" :parsing]
[1:41:53][Make our assembler multi-pass, introducing init_pass()][:asm :"code generation" :parsing]
[1:47:14][:Run it to see that it worked][:asm :"code generation" :parsing]
[1:47:54][Recap how the assembler's passes work][:asm :"code generation" :parsing :speech]
[1:50:41][Q&A][:speech]
[1:51:11][@xanatos387][I was curious about the sections earlier. The explanation makes sense. I guess we'll start out with a flat model, and at some point as the :hardware / OS gets more advanced we'd need sections?][:"operating system"]
[1:53:39][@navastyles][@pervognsen How many assemblers have you made?]
[1:54:23][That's it for today][:speech]
[/video]
