cinera_handmade.network/pervognsen/bitwise/bitwise/bitwise036.hmml

73 lines
5.0 KiB
Plaintext

[video member=pervognsen stream_platform=twitch project=bitwise title="Forth Implementation, Part 2" vod_platform=youtube id=SPErnyotJrk annotator=Miblo]
[0:08][Recap and set the stage for the day][:speech]
[0:52][Review the off-stream work on next and the addition of do_twice and docol with indirect :threading in our FORTH implementation][:asm :research]
[7:51][Describe our test program and its control flow][:asm :research]
[11:33][Demo the program][:asm :emulation :run]
[12:25][A few words on :threading in JONESFORTH[ref
site=GitHub
page="nornagon / jonesforth"
url=https://github.com/nornagon/jonesforth]][:asm :speech]
[13:15][Implement user-defined words with indirect :threading][:asm]
[16:53][:Run it and hit an "Expected instruction or command" error][:asm :emulation]
[17:11][Change do_twice and do_jump to use .org + 8][:asm]
[17:38][:Run it and hit an "Operand must be constant" error][:asm :emulation]
[18:11][Enable cmd_org() to parse address offsets][:parsing]
[18:49][:Run it to see that it still works, recapping that change][:asm :emulation]
[19:35][Rename the existing defword to defcode, and introduce a new defword to handle user-defined words][:asm]
[20:51][:Run it to see that it still works][:asm]
[21:01][Up- / downsides of user-defined words][:asm :speech]
[23:44][Change defcode and defword to an indirect :threading scheme][:asm]
[24:56][:Run it to see that it does work][:asm]
[25:05][The minimum set of FORTH runtime semantics][:asm :speech]
[26:27][FORTH dictionary][:asm :speech]
[31:57][Defining a dictionary in FORTH, including its \: and ; syntax][:asm :language :speech]
[33:45][Set up to implement dictionary][:asm :speech]
[34:51][Introduce cmd_str() and cmd_str() in the assembler]
[36:42][Begin to implement dictionary entry][:asm]
[39:26][Enable defcode and defword to support definition naming][:asm]
[43:04][:Run it and hit an "Unexpected token (null) in expression" error][:asm]
[44:35][Add TOKEN_STR to the token_kind_names table][:parsing]
[45:07][:Run it and step through to investigate the bug][:asm]
[47:55][Fix defcode and defword to use $label rather than $name][:asm]
[48:14][:Run it to find that it doesn't still work][:asm :emulation]
[50:23][Reorganise docol and fix init to initialise the rsp (return stack pointer)][:asm]
[52:36][:Run it to find that it handles our input][:asm :emulation]
[53:37][Make defcode print the address and name][:asm]
[54:21][:Run it to see our defined codes, that reg 4 contains an odd-numbered address, and we get to an ILLEGAL instruction][:asm]
[56:17][Note that JALR rounds to two-byte boundaries, and enable defcode to align 4 after the .str instruction]
[57:58][:Run it and step through the :emulation to still see unaligned address][:asm]
[59:03][Fix defcode to correctly compute the alignment][:memory]
[59:22][:Run it to find that our addresses are aligned, but our input is not being handled][:asm :emulation]
[1:00:36][Fix both defword and defcode to compute the alignment in such a way that enables :"input handling" to work][:asm]
[1:01:24][:Run it to see that it works][:asm :emulation]
[1:01:35][Initialise our dictionary's latest field, introducing defentry and a find routine][:asm]
[1:18:25][Spec out a find routine in pseudo-C code to use as a template for the assembly][:asm :speech]
[1:35:26][Paste this find routine into our FORTH implementation][:asm]
[1:42:42][:Run it to find that it assembled][:asm]
[1:43:01][Try out our find routine][:asm]
[1:45:58][:Run it and step through the :emulation][:asm]
[1:47:12][Fix temp_str_len to be a constant, not a label][:asm]
[1:47:31][Step through our find routine to find garbage in x11][:asm :emulation :run]
[1:49:37][Fix find to compare t2 (rather than t3) with t4][:asm]
[1:49:44][Step through our find routine][:asm :emulation :run]
[1:51:09][Fix find to load into t4 using lbu rather than lw][:asm]
[1:51:29][:Run it to see that x11 contains 3][:asm :emulation]
[1:53:05][Fix the alignment computation in defentry][:asm]
[1:53:56][Step through our find routine to find garbage in x14][:asm :emulation :run]
[1:55:27][Fix find to load into t7 and t8 using lbu][:asm]
[1:56:33][Step through find to find that it found a match][:asm :emulation :run]
[1:58:39][Define _putdigit and _getdigit to provide a pause-point][:asm :"input handling"]
[1:59:55][:Run it to find that it always prints 4][:asm :emulation]
[2:00:16][Define a drop word][:asm]
[2:00:56][:Run it to find that it still prints 4][:asm :emulation]
[2:01:14][Fix find to push t1 correctly onto the stack][:asm]
[2:01:26][:Run it to find that it correctly prints 1][:asm :emulation]
[2:01:32][Change temp_str to push "\@" rather than "!"][:asm]
[2:01:40][:Run it to find that it seems to work on all our test strings][:asm :emulation]
[2:02:13][Enable find to push two strings][:asm]
[2:03:19][:Run it to determine that it works, with a few words on adapting pseudo-C to assembly][:asm :emulation]
[2:04:41][Glimpse into making a command interpreter and compiler][:asm :speech]
[2:05:31][@nodist_io][What's ion in your bitwise repo?]
[2:06:07][That was it for today][:speech]
[/video]