From d35850149cb14124c74e8bc316d1a316a57284d5 Mon Sep 17 00:00:00 2001 From: Matt Mascarenhas Date: Fri, 29 Jun 2018 20:18:09 +0100 Subject: [PATCH] Annotate riscy060_2 --- miotatsu/riscy/riscy/riscy060_2.hmml | 97 +++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/miotatsu/riscy/riscy/riscy060_2.hmml b/miotatsu/riscy/riscy/riscy060_2.hmml index 3380c0d..23d1b55 100644 --- a/miotatsu/riscy/riscy/riscy060_2.hmml +++ b/miotatsu/riscy/riscy/riscy060_2.hmml @@ -1,2 +1,97 @@ -[video member=miotatsu stream_platform=twitch project=riscy title="Hello World in RISC-V ASM (2/2)" vod_platform=youtube id=bFsmu0mcM-k annotator=] +[video member=miotatsu stream_platform=twitch project=riscy title="Hello World in RISC-V ASM (2/2)" vod_platform=youtube id=bFsmu0mcM-k annotator=Miblo] +[0:01][Welcome to the stream][:speech] +[0:33][Review additions to the Useful Links: unistd.h[ref + site=GitHub + page="linux / include / uapi / asm-generic / unistd.h" + url=https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/unistd.h] and RISC-V: Linux Syscall Interface[ref + site=Sourceware + page="[PATCH 10/12] RISC-V: Linux Syscall Interface" + url=https://sourceware.org/ml/libc-alpha/2017-06/msg00626.html]][:research] +[2:48][@polytomous][Unfortunately don't have time to watch, but I just came by to say that your title is great] +[3:02][Continue reading through the RISC-V Linux Syscall Interface[ref + site=Sourceware + page="[PATCH 10/12] RISC-V: Linux Syscall Interface" + url=https://sourceware.org/ml/libc-alpha/2017-06/msg00626.html]][:research] +[4:16][@polytomous][You best stream soon so I can actually watch you work on this project[ref + site=YouTube + page="RISCY BUSINESS" + url=http://riscy.tv/]] +[4:55][Finish reading through the RISC-V Linux Syscall Interface[ref + site=Sourceware + page="[PATCH 10/12] RISC-V: Linux Syscall Interface" + url=https://sourceware.org/ml/libc-alpha/2017-06/msg00626.html]][:research] +[5:34][Return to hello.S assembly and include the li and mv instructions in loop 1][:asm] +[6:45][@JumpOnMeh][Hi, are you coding on a Raspberry Pi?] +[7:32][Lower the exit call in main() from hula to assembly][:asm] +[8:58][@JumpOnMeh][If you don't mind me asking, what is RISC-V?[ref + site=RISC-V + url=https://riscv.org/]] +[11:02][Set up to lower the return call in main() from hula to assembly][:asm :speech] +[11:13][@JumpOnMeh][I'm taking a degree in comp sci right now. Kinda interested in learning new languages][:language] +[11:40][Plug ~bitwise[ref + site=Bitwise + url=https://bitwise.handmade.network/]][:speech] +[13:14][Lower the return call in main() from hula to assembly][:asm] +[14:27][Compare our newly written RISC-V assembly with hello.S in the repo,[ref + site=GitLab + page="hula / hello.S" + url=https://gitlab.com/riscy-business/hula/blob/master/hello.S] and consult the RISC-V ELF psABI specification[ref + site=GitHub + page="RISC-V ELF psABI specification" + url=https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md] for documentation on the stack frame][:research] +[17:54][Push the return address of main onto the stack][:asm] +[21:14][A few words on generating the code for multiple returns, wondering what [@pervognsen Per] has to say about it][:"code generation" :speech] +[22:12][Enable main to correctly return from all branches, and offset the stack pointer[ref + site=GitLab + page="hula / hello.S" + url=https://gitlab.com/riscy-business/hula/blob/master/hello.S]][:asm] +[30:32][A few words on using the temporary "a" registers, and the possible :performance ramifications of being tight with register usage][:speech] +[32:31][Enable main to reuse the a1 register][:asm] +[34:28][Fix main to correctly break out of the print loop][:asm] +[36:48][Read through hello.S to check it all looks correct][:asm :research] +[40:08][Fix _start to correctly pop the loaded word off the stack][:asm] +[40:31][Finish reading through hello.S and consider it all good][:asm :research] +[41:15][Assemble our program to see :assembly errors] +[42:13][Remove comment and fix :assembly errors] +[42:42][Assemble our program to see errors on bez and beq][:asm] +[44:27][Grab the RISC-V Reader[ref + title="RISC-V Reader" + author="David Patterson and Andrew Waterman" + publisher="Strawberry Canyon" + isbn=9780999249116 + url=http://www.riscvbook.com/]][:admin] +[45:24][Rename bez to beqz, and fix our beq calls, in conjunction with the RISC-V Reader[ref + title="RISC-V Reader" + author="David Patterson and Andrew Waterman" + publisher="Strawberry Canyon" + isbn=9780999249116 + url=http://www.riscvbook.com/]][:asm] +[46:48][Consult the RISC-V Reader[ref + title="RISC-V Reader" + author="David Patterson and Andrew Waterman" + publisher="Strawberry Canyon" + isbn=9780999249116 + url=http://www.riscvbook.com/] for information on loading into the frame pointer][:asm :research] +[51:12][Try to make _start load 0 into s0 rather than fp][:asm] +[51:55][Assemble it to see that this fixed that error][:asm] +[52:44][Stick .section in front of .rodata as per the RISC-V Reader[ref + title="RISC-V Reader" + author="David Patterson and Andrew Waterman" + publisher="Strawberry Canyon" + isbn=9780999249116 + url=http://www.riscvbook.com/]][:asm] +[53:08][Assemble it successfully][:asm] +[54:07][Link our program with ld][:asm] +[54:20][:Run it to see that it works][:asm] +[54:41][Inspect our binary][:research] +[56:00][On writing this program as an example of code that hula should compile to][:asm :language :speech] +[56:18][Streamline the return code loads in main][:asm] +[1:00:37][Prevent _start from zeroing out the frame pointer][:asm] +[1:02:23][Assemble and link it][:asm] +[1:02:36][:Run it to see that it still works][:asm] +[1:02:45][Consider the episode done, with a glimpse into the future booting Fedora directly, hand-writing the machine code for our "Hello, World!" and covering compressed instructions][:asm :speech] +[1:07:32][Thoughts on avoiding :security vulnerabilities by owning the entire chain of production][:fabrication :hardware :speech] +[1:12:57][Further thoughts on the elegance of FORTH and its suitability for bootstrapping][:asm :speech] +[1:15:50][Glimpse into the future designing a custom case, streaming from our RISC-V system and building a Linux distribution for it][:speech] +[1:17:16][End this episode here][:speech] [/video]