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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Show HN: A toy bootloader written in C++

64 点作者 st_goliath大约 2 年前
Yes, this includes the MBR and partition boot sector. The partition table is modeled as a class hierarchy. Second stage loads a kernel from a FAT32 file.<p>I&#x27;m normally a C programmer, but for a work project, I recently revisited C++, a language that I had an on-again-off-again relationship over the years.<p>I did this as a fun training exercise on the side to get familiar with the language again, but obsessed a bit and kind of overshot the target. I thought the result might be of interest to someone.

5 条评论

leetrout大约 2 年前
When talking about a compiler course<p>&gt;&gt;&gt; To a degree, it changed my way of thinking about programming. Source code should first and foremost be written for people to read. Source code should convey high level meaning, both to people, as well as to the compiler. Bit twiddling hacks are an utter waste of time and make the job harder for the compiler as well. Keeping down asymptotic complexity is your job, optimizing the coefficient is the compilers job (but you should really be thinking in terms of data structures anyway, rather than algorithms).<p>Thank you for that. Sometimes I feel like we don&#x27;t give enough permission to &quot;just&quot; be a developer and focus on writing simple, understandable code.<p>Maybe not what you intended but it resonated with me.
评论 #35491147 未加载
评论 #35491704 未加载
mtlynch大约 2 年前
This is cool! Thank you for sharing!<p>I&#x27;ve fantasized about doing something similar. What resources did you find helpful in learning to do this? What would you estimate was your time investment to get it working?
评论 #35492293 未加载
todd8大约 2 年前
I once wrote a Boot loader for a minicomputer that had a card reader. One card holds 80 chars and a physical buttons on the machine would load those bytes into low memory and set the program counter to the address of the first byte. I could just squeeze in enough binary machine instructions that loaded 6 more cards of machine code that made up the rest of the boot loader. That way, a user could put these 7 cards on the front of any program they wanted to run and put it all into the card reader.<p>Things were actually a bit more complex, a FORTRAN program would require the compiler to be next in the stack followed by the user’s FORTRAN code and then the data that would be data read by the program.<p>The goal of this reading one card that would read more cards was to minimize the amount of switches that had to be set on the front panel to kick off the whole sequence. One card couldn’t even hold the final branch for the machine language loop that read cards 2 through 7. That branch instruction was at the front of card 2 that has been read into into memory by the body of the loop.<p>TLDR: lots of bit twiddling was needed to create an ergonomic loader.
评论 #35492895 未加载
gjvc大约 2 年前
Great job! This will be of much help to people writing toy OSes :-)
ngneer大约 2 年前
Wow, very nice work!