TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: RISC-V core written in 600 lines of C89

190 点作者 mnurzia将近 2 年前

13 条评论

aportnoy将近 2 年前
How about a RISC-V disassembler in 200 lines of C99?<p><a href="https:&#x2F;&#x2F;github.com&#x2F;andportnoy&#x2F;riscv-disassembler&#x2F;blob&#x2F;master&#x2F;das.c">https:&#x2F;&#x2F;github.com&#x2F;andportnoy&#x2F;riscv-disassembler&#x2F;blob&#x2F;master...</a>
评论 #36270759 未加载
bjourne将近 2 年前
Why stick with c89? Can&#x27;t think of any compilers that doesn&#x27;t support c99 nowadays. The major benefit is that you can use uint8_t and friends directly and don&#x27;t need to define your own wrapper types.
评论 #36271066 未加载
评论 #36274018 未加载
评论 #36273351 未加载
评论 #36271024 未加载
评论 #36271493 未加载
garganzol将近 2 年前
Seeing the RISC-V instructions implemented in the emulator like that, it comes to my mind that RISC-V is really a reduced instruction set CPU.<p>When compared to AVR 16-bit RISC instruction set, RISC-V looks so much simpler. (You may be indirectly familiar with AVR architecture by the household name &quot;Arduino&quot;.)<p>The intriguing part is that AVR is just a microcontroller, while RISC-V is intended to be a full-blown CPU.
评论 #36273563 未加载
评论 #36277790 未加载
bitwize将近 2 年前
I feel myself descending into old-fartitude more and more with every year. My wife and I were recently involved in a car accident (no one was hurt). While I was being checked out I overheard a 20-year-old firefighter exchange Facebook information with an 18-year-old EMT. I was like, &quot;wait a minute, you guys seem really young and you still use Facebook? I thought Facebook was for your grandparents and all the kids now use Snapchat or TikTok?&quot;<p>I get that same feeling now. This kid is 20 and still using C89? Shouldn&#x27;t people his age have been reared entirely in the crystal-spires-and-togas utopia of Rust, with raw pointers and buffer overruns being mere legends of their people&#x27;s benighted past told to them by their elders?<p>It&#x27;s kind of comforting to see young programmers embracing the old ways, even if it&#x27;s for hack value only.
评论 #36275564 未加载
评论 #36272656 未加载
nevi-me将近 2 年前
Question: do the implementation of single instructions compile to single instructions if targeting RISC-V with optimisations enabled? That would be really awesome if compilers realise what your code is doing and replace the implementations of instructions with those instructions.
评论 #36271391 未加载
评论 #36271320 未加载
peterfirefly将近 2 年前
&#x27;switch&#x27; is a really, really nice language construct that was fully implemented long before C89. Using lots of nested &#x27;if&#x27;s instead is not a good idea.
评论 #36271094 未加载
评论 #36270585 未加载
freecodyx将近 2 年前
This proves that at the core. The things we rely on to achieve great software and life impacting technologies are extremely simple. The complexity is that how to make them.
评论 #36273879 未加载
评论 #36274969 未加载
charcircuit将近 2 年前
This isn&#x27;t a RISC-V core. It is a RISC-V emulator library.
sylware将近 2 年前
A bigger implementation, but has 64bits support:<p><a href="https:&#x2F;&#x2F;bellard.org&#x2F;tinyemu&#x2F;" rel="nofollow">https:&#x2F;&#x2F;bellard.org&#x2F;tinyemu&#x2F;</a>
RobotToaster将近 2 年前
Is this designed to be used with some kind of C to VHDL&#x2F;verilog transpiler?
评论 #36270643 未加载
userbinator将近 2 年前
Besides not using a switch() for the main instruction decode, there&#x27;s nothing surprising here. Anyone who has worked with emulators before will find this code straightforward to read. RISC-V really is the new MIPS.
rowanG077将近 2 年前
The Readme doesn&#x27;t answer it but I struggle to see why you want a c implementation of an ISA.
评论 #36271635 未加载
评论 #36270553 未加载
评论 #36270729 未加载
评论 #36270569 未加载
sutterbutter将近 2 年前
As a total newb to programming, what am I looking at here?
评论 #36274895 未加载