LWN: Comments on "An introduction to RISC-V" https://lwn.net/Articles/749185/ This is a special feed containing comments posted to the individual LWN article titled "An introduction to RISC-V". en-us Sat, 04 Oct 2025 17:22:55 +0000 Sat, 04 Oct 2025 17:22:55 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net An introduction to ugly RISC-V assembler https://lwn.net/Articles/750078/ https://lwn.net/Articles/750078/ Jonno <div class="FormattedComment"> <font class="QuotedText">&gt; Yes I find the MIPS-inspired asm to be annoying, particularly the fact that there's no common concept of source and destination, eg: </font><br> <p> In RISC-V assembler the destination (if any) always come first. However, note that the non-atomic store instructions (sd, sw, sh, and sb) does not have a destination, only two operands (a value and an address) and a side effect (a memory write)...<br> </div> Sun, 25 Mar 2018 14:53:03 +0000 An introduction to ugly RISC-V assembler https://lwn.net/Articles/750002/ https://lwn.net/Articles/750002/ rwmj <p> Yes I find the MIPS-inspired asm to be annoying, particularly the fact that there's no common concept of source and destination, eg: <pre> li a0, immediate # dst, src lw a0, addr # dst, src sw a0, addr # src, dst </pre> <p> I also programmed the 68k and Z80 as a commercial programmer back in the day, but I recognize that few people are hand coding large volumes of asm these days, even for embedded platforms. <p> In fact with complex rules for immediate loads, pervasive use of pseudo instructions (both lw and sw above aren't "real" instructions, they expand to one or two base instructions), "linker relaxation", compressed instructions, superscalar, macro-op fusion etc I doubt it's really feasible. Fri, 23 Mar 2018 11:20:44 +0000 An introduction to ugly RISC-V assembler https://lwn.net/Articles/749970/ https://lwn.net/Articles/749970/ farnz <p>RISC-V looks a lot more like MIPS or PowerPC to me than it does to x86 or 68k. Thu, 22 Mar 2018 15:10:44 +0000 An introduction to ugly RISC-V assembler https://lwn.net/Articles/749966/ https://lwn.net/Articles/749966/ deater <div class="FormattedComment"> <font class="QuotedText">&gt; But I guess they wanted to look like ugly and stupid x86</font><br> <p> I don't want to get involved in an assembly-language beauty discussion, but if you know anything about the history of RISC-V and the people involved it's pretty clear RISC-V assembly language is more or less exactly the same as MIPS.<br> <p> The main thing I have against MIPS assembly is that there are two names for each register (the generic one, and then the mnemonic one (such as a0, s0, etc.)) and it can get really confusing trying to remember the mapping between them.<br> </div> Thu, 22 Mar 2018 14:42:38 +0000 An introduction to ugly RISC-V assembler https://lwn.net/Articles/749940/ https://lwn.net/Articles/749940/ kragil <div class="FormattedComment"> I wish they would have used assember like the Motorola 68xxx. It was so much nicer!<br> One example:<br> move.w #$500,d0<br> moves the word hex 500 to d0. The list would go on and on. It was so much more readable and nicer than x86-assembler. <br> But I guess they wanted to look like ugly and stupid x86 for some reason (IMNSHO). <br> </div> Thu, 22 Mar 2018 13:02:54 +0000 An introduction to RISC-V https://lwn.net/Articles/749544/ https://lwn.net/Articles/749544/ rwmj <div class="FormattedComment"> It should read "address of the first byte". It's definitely not possible to determine this from the first byte of an x86 instruction, eg. the LOCK prefix is a counterexample.<br> </div> Sat, 17 Mar 2018 14:50:35 +0000 An introduction to RISC-V https://lwn.net/Articles/749541/ https://lwn.net/Articles/749541/ ianmcc <div class="FormattedComment"> I am surprised it is possible to determine the length of an x86 instruction after just one byte. What about prefixes?<br> </div> Sat, 17 Mar 2018 13:53:03 +0000 An introduction to RISC-V https://lwn.net/Articles/749445/ https://lwn.net/Articles/749445/ flussence <div class="FormattedComment"> Oh, it's right there in section 12.7: 16 bit instructions unless the bottom two bits are set, then it's a long instruction. That looks pretty similar to how websockets encodes length, makes sense to me now. Thanks.<br> </div> Thu, 15 Mar 2018 20:08:51 +0000 An introduction to RISC-V https://lwn.net/Articles/749356/ https://lwn.net/Articles/749356/ rwmj <p>&gt;<i>I'll take “horrible to decode” at face value in any case</i> <p> The Linux kernel is capable of decoding the length of an x86 instruction, given the first byte. The code is fairly intricate: <a href="https://github.com/torvalds/linux/blob/master/arch/x86/lib/insn.c">arch/x86/lib/insn.c</a> <p> Initial 8086 chips didn't have to worry about instruction boundaries because the microcode fetched, decoded and executed bytes one at a time. Over time <a href="http://www.agner.org/optimize/blog/read.php?i=25">x86 encoding has piled complexity on complexity</a>. Now we know that instruction prefetch queues are a thing and that you have to split on instruction boundaries early so it's possible to design something to make this much simpler. Thu, 15 Mar 2018 07:58:50 +0000 An introduction to RISC-V https://lwn.net/Articles/749350/ https://lwn.net/Articles/749350/ roc <div class="FormattedComment"> <a href="https://riscv.org/specifications/">https://riscv.org/specifications/</a> chapter 12.<br> <p> You can figure out the length of an instruction by decoding the first 16 bits, and 16 bits is the minimum instruction length. (This might change if they ever decide to add instructions more than 24 bytes long.)<br> <p> The bytes of an instruction after the first 16 bits can be anything, so there is no way, given an arbitrary address, to reliably find the start or end of the instruction, unlike UTF8 where given a pointer you can find the start and end of the character. This seems like an OK tradeoff though.<br> </div> Thu, 15 Mar 2018 03:57:04 +0000 An introduction to RISC-V https://lwn.net/Articles/749340/ https://lwn.net/Articles/749340/ flussence <div class="FormattedComment"> <font class="QuotedText">&gt; Unlike x86, variable length does not have to mean "horribly complex to decode". The encoding ensures that the processor can easily see the length of every instruction in its prefetch queue by decoding a few bits in a uniform location.</font><br> Just wondering aloud, as I have no idea where to begin to look this up: does it resemble UTF-8 with a unary length prefix (but without UTF-8's other inefficiencies)? Or is it something different? I'm curious what works best for hardware with no legacy compat to worry about.<br> <p> (I'll take “horrible to decode” at face value in any case - I can't even make sense of x86's mnemonic names most of the time!)<br> </div> Thu, 15 Mar 2018 00:05:19 +0000 An introduction to RISC-V https://lwn.net/Articles/749314/ https://lwn.net/Articles/749314/ JoelSherrill <div class="FormattedComment"> Sorry for not pointing that out also. RTEMS uses the FreeBSD TCP/IP stack among other pieces.<br> </div> Wed, 14 Mar 2018 18:41:48 +0000 An introduction to RISC-V https://lwn.net/Articles/749313/ https://lwn.net/Articles/749313/ willy <div class="FormattedComment"> There's also at least a FreeBSD port to RISC-V:<br> <a href="https://wiki.freebsd.org/riscv">https://wiki.freebsd.org/riscv</a><br> </div> Wed, 14 Mar 2018 18:31:14 +0000 An introduction to RISC-V https://lwn.net/Articles/749299/ https://lwn.net/Articles/749299/ JoelSherrill <div class="FormattedComment"> Thanks for the article. Linux is not the only free OS supporting RISC-V. The free real-time operating system RTEMS (RTEMS.org) also has a port to the 32 and 64-bit RISC-V. <br> </div> Wed, 14 Mar 2018 16:58:47 +0000