[video member=pervognsen stream_platform=twitch project=bitwise medium=speech title="How To Program Assembly Language, Part 2" vod_platform=youtube id=GrZnxHYmir0 annotator=Miblo] [0:08][Recap and set the stage for the day][:asm] [1:41][Continuation on the lack of a carry flag in RISC-V and MIPS, and how the RISC-V Instruction Set Manual suggests doing unsigned overflow checking[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 :isa :mathematics] [7:36][Larger-than-word sized (64-bit) multiplication in RISC-V[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 :isa :mathematics] [14:39][64-bit comparisons in terms of 32-bit comparisons][:asm :isa] [17:42][Larger-than-word division in RISC-V, briefly[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 :isa :mathematics] [20:37][Lowering array indexing implemented via pointer arithmetic, from C to assembly][:asm :language :memory] [26:43][@tbodt_][Are ah / al like in x86?][:isa] [27:18][Naively lowering pointer subtraction from C to assembly[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 :language :mathematics] [34:48][Inspect the debug-built assembly of pointer subtraction][:asm :run] [36:56][Inspect the release-built assembly of pointer subtraction][:asm :performance :run] [41:17][Structs and unions in C][:asm :language :"data structure"] [44:18][Lowering a variable-initialisation-from-struct-field from C to assembly][:asm :"data structure" :language] [52:33][Loading / storing multiple fields by exploiting the load / store addressing modes with immediate offsets][:asm :"data structure" :isa :language] [58:19][Knowing the ABI's size and alignment conventions when calculating offsets and sizes for structs][:asm :"data structure" :language] [1:01:33][Unions, handling overlapping offsets][:asm :"data structure"] [1:05:01][Structured control flow][:asm :language] [1:08:07][@davechat][@pervognsen Who invented structured control flow?][:language] [1:09:07][Recommend Knuth's 'Structured programming with go to statements'[ref author="Donald E. Knuth" title="Structured programming with go to statements" url=http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.103.6084]][:programming :research] [1:14:52][Structured if (without else)][:asm :language] [1:17:24][Structured if-else][:asm :language] [1:19:39][@teamrandb][Does [@pervognsen Per] answer questions regarding earlier streams, or is it better to just ask in discord, to not break the current stream? (I want to ask a question regarding the hash table, what he did in 11 Extra / 12)][:"data structure"] [1:20:10][Generating more concise assembly for nested if within else scopes][:asm :"code generation" :language] [1:21:33][Structured do-while in C][:asm :language] [1:25:39][Formulating while loops as an extension of do-while][:asm :language] [1:30:00][Lowering a while loop from C to assembly][:asm :language] [1:34:23][Lowering a boolean comparison, making effective use of RISC-V's fused compare-and-branch instructions][:asm] [1:41:35][Structured short-circuiting "and" and "or"][:asm :language] [1:49:00][Glimpse into the future covering functions and handling more local variables than fit in registers] [1:50:11][Q&A] [1:50:43][@teamrandb][@pervognsen: Regarding your hash table, specifically your string intern table – str_intern_range() in common.c – I am having a hard time visualizing how it handles collisions. Assuming you are adding a new string to the existing table, and the hash collides (even if rare), when we get to map_put_hashed() (line 322?), if you used the hash as the key, won't it just override any existing hashes?][:"data structure"] [1:55:00][@teamrandb][Ah, okay. I think I get it. I guess I got confused because I thought you were doing linear probing. So the table is doing that, but the string intern is a linked list?][:"data structure"] [1:57:52][That might be it for today, with a glimpse into the future doing :hardware design] [/video]