Annotate bitwise037

This commit is contained in:
Matt Mascarenhas 2018-06-15 21:47:53 +01:00
parent 91573a9a94
commit 1b0a3de3cb
1 changed files with 69 additions and 2 deletions

View File

@ -1,2 +1,69 @@
[video member=pervognsen stream_platform=twitch project=bitwise title="Forth Implementation, Part 3" vod_platform=youtube id=TA8blMaNqxY annotator=]
[/video]
[video member=pervognsen stream_platform=twitch project=bitwise title="Forth Implementation, Part 3" vod_platform=youtube id=TA8blMaNqxY annotator=Miblo]
[0:08][Recap and set the stage for the day continuing with our FORTH implementation][:speech]
[1:04][Review the dictionary entry data format][:asm :"data structure" :research]
[3:09][Review the find routine, with a mention of its composition begun in higher level C code][:asm :research]
[9:00][Review the current program, noting that find could have been written in FORTH][:asm :research]
[11:04][Dive into buffered input, beginning in C before adapting it to assembly][:asm :memory]
[22:03][Reflect on the intention of this code to be easily translatable from C to assembly][:asm :speech]
[22:36][Translate our buffered input implementation from C to assembly][:asm :memory]
[33:19][@twitchplaysp0ng][Which registers are callee saved?][:memory]
[33:53][@davechat][I think you need to increment input pointer after char *c = *input; otherwise you have an infinite loop?]
[34:29][Correctly increment input and continue adapting it from C to assembly][:asm :memory]
[37:55][Paste our buffered input implementation into forth.asm][:asm :memory]
[39:29][:Run it to see that it assembles][:asm :"input handling" :memory]
[39:36][@twitchplaysp0ng][Last comment is wrong. The comment should be sp\[-1\]]
[39:45][Fill our input_buf with the string "foo bar" and try it out][:asm :memory]
[43:09][:Run it to see what it does][:asm :"input handling" :memory]
[43:33][Make our program _drop after doing _putdigit and _getdigit][:asm :memory]
[44:23][Print out the address of word_][:asm :"input handling"]
[44:35][Step through the simulation to see what it does][:asm :emulation :memory :run]
[45:50][Renumber the registers][:asm :memory]
[47:26][Fix print_hart_state() to display 31 registers (down from 32)]
[49:29][Step through it to see what it does][:asm :emulation :memory :run]
[51:14][Fix word_ to store back the updated input value][:asm]
[52:43][Step through it to see what it does][:asm :emulation :memory :run]
[53:29][Fix word_ to load the input as a byte (lbu) rather than a word (lw)][:asm :memory]
[54:00][:Run it to see that it works as expected][:asm :memory]
[55:08][Fix word_ to correctly initialise t5 to t4 (char *ptr = start)][:asm :memory]
[55:46][:Run it to see that we're good][:asm :memory]
[56:06][Further test our word_ using "per vognsen"][:asm :memory :programming :run]
[57:08][@twitchplaysp0ng][What's it printing?]
[58:18][Review our bugs in the assembly code][:asm :research]
[1:00:25][Introduce _nez word in FORTH, and cmd_seqz() and cmd_snez() instructions in the assembler[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]
[1:08:30][Make our FORTH program call _nez after _word and _find][:asm]
[1:08:53][:Run it to see all 0s, because neither "per" nor "vognsen" are words in our dictionary][:asm]
[1:09:06][Edit our input buffer to test dictionary matching][:asm]
[1:09:57][:Run it to see that it all works][:asm]
[1:10:05][Introduce _execute word][:asm]
[1:14:08][:Run it to see that it prints 9][:asm]
[1:14:18][Introduce _xt to push an execution token onto the stack][:asm]
[1:17:36][Set up our program to test _xt and _execute][:asm]
[1:18:36][Define _0 and _1 to get things going without having an integer parser][:asm]
[1:20:14][:Run it to see that it does jack shit][:asm]
[1:20:31][Print out matching of our test string with the dictionary][:asm]
[1:20:48][:Run it to see that "1" matches, but "putdigit" doesn't][:asm]
[1:21:47][Change our test string to "1 1 +"][:asm]
[1:21:54][:Run it to see that the last thing never matches][:asm]
[1:22:03][Change our test string to "1 1 + putdigit _"][:asm]
[1:22:22][:Run it to see that "putdigit" never matches][:asm]
[1:22:55][Rename the _add word as "+"][:asm]
[1:23:09][:Run it to see that everything except "putdigit" matches][:asm]
[1:24:05][Define everyone, including _putdigit, before latest_const][:asm]
[1:25:03][:Run it to see that it works][:asm]
[1:25:16][Enable our FORTH program to execute the words in our string][:asm]
[1:25:44][:Run it to see what happens][:asm]
[1:26:51][Try testing _xt with known data][:asm]
[1:27:49][:Run it to see that it prints 9][:asm]
[1:27:52][Label _putdigit putdigit_entry][:asm]
[1:28:20][:Run it to see that it does not work][:asm]
[1:28:27][Investigate the problem, presumably in _xt][:asm :research]
[1:29:39][Step through it to see what it's doing][:asm :emulation :run]
[1:30:57][Fix _xt to correctly increment t1][:asm]
[1:32:27][:Run it to see that it works][:asm]
[1:33:05][Reorganise the program][:asm]
[1:33:58][Consider our next steps: reading from the keyboard, and appending definitions for future execution][:asm :"input handling" :speech]
[1:36:43][That's it for today][:speech]
[/video]