Bitwise»Episode Guide
Assembler Macro Expansion
?
?

Keyboard Navigation

Global Keys

[, < / ], > Jump to previous / next episode
W, K, P / S, J, N Jump to previous / next marker
t / T Toggle theatre / SUPERtheatre mode
V Revert filter to original state Y Select link (requires manual Ctrl-c)

Menu toggling

q Quotes r References f Filter y Link c Credits

In-Menu Movement

a
w
s
d
h j k l


Quotes and References Menus

Enter Jump to timecode

Quotes, References and Credits Menus

o Open URL (in new tab)

Filter Menu

x, Space Toggle category and focus next
X, ShiftSpace Toggle category and focus previous
v Invert topics / media as per focus

Filter and Link Menus

z Toggle filter / linking mode

Credits Menu

Enter Open URL (in new tab)
0:07Recap and set the stage for the day
🗩
0:07Recap and set the stage for the day
🗩
0:07Recap and set the stage for the day
🗩
1:05Review the new cmd_la() pseudo-instruction
📖
1:05Review the new cmd_la() pseudo-instruction
📖
1:05Review the new cmd_la() pseudo-instruction
📖
4:03Review the new two-operand syntax for three-operand instructions
📖
4:03Review the new two-operand syntax for three-operand instructions
📖
4:03Review the new two-operand syntax for three-operand instructions
📖
5:48Review the new partial inference of immediates from operands
📖
5:48Review the new partial inference of immediates from operands
📖
5:48Review the new partial inference of immediates from operands
📖
7:52Review the new support for '.' being the first character of an identifier
📖
7:52Review the new support for '.' being the first character of an identifier
📖
7:52Review the new support for '.' being the first character of an identifier
📖
9:35Review the new '>' and '<' jump-to-label directives, inspired by the NES Metroid source1
📖
9:35Review the new '>' and '<' jump-to-label directives, inspired by the NES Metroid source1
📖
9:35Review the new '>' and '<' jump-to-label directives, inspired by the NES Metroid source1
📖
15:38Describe the implementation of anonymous labels
📖
15:38Describe the implementation of anonymous labels
📖
15:38Describe the implementation of anonymous labels
📖
19:43Review the load immediate and mov pseudo-instructions
📖
19:43Review the load immediate and mov pseudo-instructions
📖
19:43Review the load immediate and mov pseudo-instructions
📖
21:53Q&A
🗩
21:53Q&A
🗩
21:53Q&A
🗩
22:03twitchplaysp0ng Shouldn't 1545 be "lw x3, [val]"?
🗪
22:03twitchplaysp0ng Shouldn't 1545 be "lw x3, [val]"?
🗪
22:03twitchplaysp0ng Shouldn't 1545 be "lw x3, [val]"?
🗪
23:06miotatsu I like all your changes personally, the only thing I would do different is dropping number labels and using the <# ># syntax for referring to anonymous labels. But it's all bikeshed discussion really
🗪
23:06miotatsu I like all your changes personally, the only thing I would do different is dropping number labels and using the <# ># syntax for referring to anonymous labels. But it's all bikeshed discussion really
🗪
23:06miotatsu I like all your changes personally, the only thing I would do different is dropping number labels and using the <# ># syntax for referring to anonymous labels. But it's all bikeshed discussion really
🗪
26:35Macro Expansion
🗩
26:35Macro Expansion
🗩
26:35Macro Expansion
🗩
28:07Macros, Constant and Parameterized
🗩
28:07Macros, Constant and Parameterized
🗩
28:07Macros, Constant and Parameterized
🗩
30:30Spec'ing out our macros syntax, and considering how to implement it
🗩
30:30Spec'ing out our macros syntax, and considering how to implement it
🗩
30:30Spec'ing out our macros syntax, and considering how to implement it
🗩
32:50Dive right in to implementing macro expansion, separating out next_token() into a new scan_token() function
32:50Dive right in to implementing macro expansion, separating out next_token() into a new scan_token() function
32:50Dive right in to implementing macro expansion, separating out next_token() into a new scan_token() function
43:07Run it to see that it does not work
🏃
43:07Run it to see that it does not work
🏃
43:07Run it to see that it does not work
🏃
43:19Fix next_token() to use the returned token from scan_token()
43:19Fix next_token() to use the returned token from scan_token()
43:19Fix next_token() to use the returned token from scan_token()
43:25Run it to see that it works
🏃
43:25Run it to see that it works
🏃
43:25Run it to see that it works
🏃
43:58Introduce the notion of a TokenList, and init_scan() to build up that list
43:58Introduce the notion of a TokenList, and init_scan() to build up that list
43:58Introduce the notion of a TokenList, and init_scan() to build up that list
51:24Run it to see that it miraculously works
🏃
51:24Run it to see that it miraculously works
🏃
51:24Run it to see that it miraculously works
🏃
51:48Stress test the error handling
🏃
🖮
51:48Stress test the error handling
🏃
🖮
51:48Stress test the error handling
🏃
🖮
54:08Augment the TokenList with an index
54:08Augment the TokenList with an index
54:08Augment the TokenList with an index
58:03Run it to see that it's okay
🏃
58:03Run it to see that it's okay
🏃
58:03Run it to see that it's okay
🏃
58:27Introduce the notion of a TokenListStack and its accompanying push_token_list() and pop_token_list() to handle "nested macro" expansion
58:27Introduce the notion of a TokenListStack and its accompanying push_token_list() and pop_token_list() to handle "nested macro" expansion
58:27Introduce the notion of a TokenListStack and its accompanying push_token_list() and pop_token_list() to handle "nested macro" expansion
1:07:54Run it to see that it seems to work
🏃
1:07:54Run it to see that it seems to work
🏃
1:07:54Run it to see that it seems to work
🏃
1:08:13Embark on the actual macro expansion, introducing cmd_define()
1:08:13Embark on the actual macro expansion, introducing cmd_define()
1:08:13Embark on the actual macro expansion, introducing cmd_define()
1:16:02Add a macro in asm_test()
1:16:02Add a macro in asm_test()
1:16:02Add a macro in asm_test()
1:16:36Run it with the macro established in the symbol table
🏃
1:16:36Run it with the macro established in the symbol table
🏃
1:16:36Run it with the macro established in the symbol table
🏃
1:16:40Enable next_token() to perform macro expansion
1:16:40Enable next_token() to perform macro expansion
1:16:40Enable next_token() to perform macro expansion
1:18:51The logic of the macro expansion
📖
1:18:51The logic of the macro expansion
📖
1:18:51The logic of the macro expansion
📖
1:19:37Fix next_token() to check that it even got a sym before checking that it is a SYM_MACRO
1:19:37Fix next_token() to check that it even got a sym before checking that it is a SYM_MACRO
1:19:37Fix next_token() to check that it even got a sym before checking that it is a SYM_MACRO
1:20:11Run it and unexpectedly hit an "Expected name, got integer" error
🏃
1:20:11Run it and unexpectedly hit an "Expected name, got integer" error
🏃
1:20:11Run it and unexpectedly hit an "Expected name, got integer" error
🏃
1:21:55Separate some of next_token() out into next_unexpanded_token(), and (temporarily?) require the use of '`' to denote the identifier in macros
1:21:55Separate some of next_token() out into next_unexpanded_token(), and (temporarily?) require the use of '`' to denote the identifier in macros
1:21:55Separate some of next_token() out into next_unexpanded_token(), and (temporarily?) require the use of '`' to denote the identifier in macros
1:28:18Run it to see that it works
🏃
1:28:18Run it to see that it works
🏃
1:28:18Run it to see that it works
🏃
1:29:32Test '`' quoting
1:29:32Test '`' quoting
1:29:32Test '`' quoting
1:29:49Run it to see that it doesn't work, and break into next_token() to investigate why
🏃
1:29:49Run it to see that it doesn't work, and break into next_token() to investigate why
🏃
1:29:49Run it to see that it doesn't work, and break into next_token() to investigate why
🏃
1:34:10Temporarily make gen_sync_pos() return without doing anything, in an effort to figure out what's wrong
1:34:10Temporarily make gen_sync_pos() return without doing anything, in an effort to figure out what's wrong
1:34:10Temporarily make gen_sync_pos() return without doing anything, in an effort to figure out what's wrong
1:35:13Make next_token() try and set the sym using get_sym() before checking that it successfully got a sym
1:35:13Make next_token() try and set the sym using get_sym() before checking that it successfully got a sym
1:35:13Make next_token() try and set the sym using get_sym() before checking that it successfully got a sym
1:37:23Narrow down our test cases in asm_test()
🏃
🖮
1:37:23Narrow down our test cases in asm_test()
🏃
🖮
1:37:23Narrow down our test cases in asm_test()
🏃
🖮
1:39:29Fix scan_str() to skip the '`'
1:39:29Fix scan_str() to skip the '`'
1:39:29Fix scan_str() to skip the '`'
1:40:07Run it to see that it works
🏃
1:40:07Run it to see that it works
🏃
1:40:07Run it to see that it works
🏃
1:40:25Test macro expansion in asm_test()
1:40:25Test macro expansion in asm_test()
1:40:25Test macro expansion in asm_test()
1:40:41Run it doing macro expansion, and hit our assertion in pop_token_list()
🏃
1:40:41Run it doing macro expansion, and hit our assertion in pop_token_list()
🏃
1:40:41Run it doing macro expansion, and hit our assertion in pop_token_list()
🏃
1:41:52Make init_pass() and lex_test() call init_scan()
1:41:52Make init_pass() and lex_test() call init_scan()
1:41:52Make init_pass() and lex_test() call init_scan()
1:42:48Step through push_token_list() to see that it all works
🏃
1:42:48Step through push_token_list() to see that it all works
🏃
1:42:48Step through push_token_list() to see that it all works
🏃
1:43:46Add a more complex macro expansion test to asm_test()
🏃
1:43:46Add a more complex macro expansion test to asm_test()
🏃
1:43:46Add a more complex macro expansion test to asm_test()
🏃
1:44:47Run it and again hit our assertion in pop_token_list()
🏃
1:44:47Run it and again hit our assertion in pop_token_list()
🏃
1:44:47Run it and again hit our assertion in pop_token_list()
🏃
1:46:30Try renaming that test macro from `x4_plus_4 to asdf
1:46:30Try renaming that test macro from `x4_plus_4 to asdf
1:46:30Try renaming that test macro from `x4_plus_4 to asdf
1:46:43Run it and hit our assertion in pop_token_list()
🏃
1:46:43Run it and hit our assertion in pop_token_list()
🏃
1:46:43Run it and hit our assertion in pop_token_list()
🏃
1:47:51Fix our asdf macro to `asdf in asm_test()
1:47:51Fix our asdf macro to `asdf in asm_test()
1:47:51Fix our asdf macro to `asdf in asm_test()
1:47:58Run it and hit our pop_token_list() assertion on the `GETCHAR macro
🏃
1:47:58Run it and hit our pop_token_list() assertion on the `GETCHAR macro
🏃
1:47:58Run it and hit our pop_token_list() assertion on the `GETCHAR macro
🏃
1:48:29Narrow down our test cases in asm_test()
🏃
🖮
1:48:29Narrow down our test cases in asm_test()
🏃
🖮
1:48:29Narrow down our test cases in asm_test()
🏃
🖮
1:48:50Run it to see that it actually works
🏃
1:48:50Run it to see that it actually works
🏃
1:48:50Run it to see that it actually works
🏃
1:49:09Rename that `asdf macro back to `x1_plus_4
1:49:09Rename that `asdf macro back to `x1_plus_4
1:49:09Rename that `asdf macro back to `x1_plus_4
1:49:28Run it to find that this works
🏃
1:49:28Run it to find that this works
🏃
1:49:28Run it to find that this works
🏃
1:49:42Uncomment the `GETCHAR macro definition in asm_test()
1:49:42Uncomment the `GETCHAR macro definition in asm_test()
1:49:42Uncomment the `GETCHAR macro definition in asm_test()
1:49:56Run it and hit our pop_token_list() assertion on that `GETCHAR definition
🏃
1:49:56Run it and hit our pop_token_list() assertion on that `GETCHAR definition
🏃
1:49:56Run it and hit our pop_token_list() assertion on that `GETCHAR definition
🏃
1:50:38Try flipping the order of the `x1_plus_4 and `GETCHAR macros
1:50:38Try flipping the order of the `x1_plus_4 and `GETCHAR macros
1:50:38Try flipping the order of the `x1_plus_4 and `GETCHAR macros
1:51:00Run it, hit our pop_token_list() assertion and consider that it's the second macro definition that asserts
🏃
1:51:00Run it, hit our pop_token_list() assertion and consider that it's the second macro definition that asserts
🏃
1:51:00Run it, hit our pop_token_list() assertion and consider that it's the second macro definition that asserts
🏃
1:52:17Make init_scan() 0-initialise the token_list_stack and rename next_unexpanded_token() to next_raw_token()
1:52:17Make init_scan() 0-initialise the token_list_stack and rename next_unexpanded_token() to next_raw_token()
1:52:17Make init_scan() 0-initialise the token_list_stack and rename next_unexpanded_token() to next_raw_token()
1:59:32Undo the buggy asm_test()
1:59:32Undo the buggy asm_test()
1:59:32Undo the buggy asm_test()
1:59:56Run it to see that it's fine
🏃
1:59:56Run it to see that it's fine
🏃
1:59:56Run it to see that it's fine
🏃
2:00:21Reflect on our macro expansion with a glimpse into the future of parameterized macros and the determination to fix the bug off-stream
🗩
2:00:21Reflect on our macro expansion with a glimpse into the future of parameterized macros and the determination to fix the bug off-stream
🗩
2:00:21Reflect on our macro expansion with a glimpse into the future of parameterized macros and the determination to fix the bug off-stream
🗩
2:03:36That's it for today's stream
🗩
2:03:36That's it for today's stream
🗩
2:03:36That's it for today's stream
🗩