kragensitaker comments on Programming thought experiment: stuck in a room with a PC without an OS.jump to contentmy subreddits<br>edit subscriptions<br>popular<br>-all<br>-users<br>| AskReddit<br>-pics<br>-funny<br>-movies<br>-gaming<br>-worldnews<br>-news<br>-todayilearned<br>-nottheonion<br>-explainlikeimfive<br>-mildlyinteresting<br>-DIY<br>-videos<br>-OldSchoolCool<br>-TwoXChromosomes<br>-tifu<br>-Music<br>-books<br>-LifeProTips<br>-dataisbeautiful<br>-aww<br>-science<br>-space<br>-Showerthoughts<br>-askscience<br>-Jokes<br>-Art<br>-IAmA<br>-Futurology<br>-sports<br>-UpliftingNews<br>-food<br>-nosleep<br>-creepy<br>-history<br>-gifs<br>-InternetIsBeautiful<br>-GetMotivated<br>-gadgets<br>-announcements<br>-WritingPrompts<br>-philosophy<br>-Documentaries<br>-EarthPorn<br>-photoshopbattles<br>-listentothis<br>-blog
more "
programmingcomments
Want to join? Log in or sign up in seconds.
limit my search to r/programminguse the following search parameters to narrow your results:<br>subreddit:subredditfind submissions in "subreddit"author:usernamefind submissions by "username"site:example.comfind submissions from "example.com"url:textsearch for "text" in urlselftext:textsearch for "text" in self post contentsself:yes (or self:no)include (or exclude) self postsnsfw:yes (or nsfw:no)include (or exclude) results marked as NSFWe.g. subreddit:aww site:imgur.com dog<br>see the search faq for details.
advanced search: by author, subreddit...
this post was submitted on 23 Oct 2009<br>304 points (88% upvoted)<br>shortlink:
Submit a new link
programming<br>joinleave/r/programming is a reddit for discussion and news about computer programming.
Rules
Refer to the rules page for more info.
No LLM-Written Content
AI-related posts must comply with the AI Policy
No Political Posts or Personal/Social Drama/Gossip
No Non-Programming/Generic LLM/Diffusion Content
No Product Promotion/"I Made This" Project Demo Posts
No Content Aggregators
No Surveys Or Job Postings
No Support Questions or AskReddit-Type Questions
No Meta Posts
No Images, Memes, Or Other Low Effort Posts
No Blogspam
No Extreme Beginner Content
Comments: No Bots
Comments: No Incivility
Info
Do you have a question? Check out /r/learnprogramming, /r/cscareerquestions, or Stack Overflow.
Do you have something funny to share with fellow programmers? Please take it to /r/ProgrammerHumor/.
For posting job listings, please visit /r/forhire or /r/jobbit.
Check out our faq. Feel free to update it!
Are you interested in promoting your own content? STOP! Read this first.
Related reddits
/r/technology
/r/ProgrammerTIL
/r/learnprogramming
/r/askprogramming
/r/coding
/r/compsci
/r/dailyprogrammer
/r/netsec
/r/webdev
/r/web_design
/r/gamedev
/r/cscareerquestions
/r/reverseengineering
/r/startups
/r/techsupport
Specific languages
a community for 20 years
MODERATORS
message the mods
939 · 160 comments<br>Announcement: We've Updated The Rules, and April Is Finally Over<br>98 · 29 comments<br>Prefer STRICT tables in SQLite<br>22<br>C3 0.8.2 A modest improvement
Integrating .NET GC in your C++ application<br>164 · 14 comments<br>Official jscrambler npm Package Compromised at 8.14.0<br>237 · 8 comments<br>How Container Networking Works: Building a Bridge Network From Scratch<br>113 · 39 comments<br>Programs, Not Objects: How I Stopped Designing Architecture and Started Writing a 3D Editor<br>Self-hosting Umami analytics on Cloudflare, Fly, and Supabase<br>186 · 126 comments<br>Quantum Computers Are Not a Threat to 128-bit Symmetric Keys<br>267 · 136 comments<br>Good Tools Are Invisible
Welcome to Reddit,<br>the front page of the internet.<br>Become a Redditorand join one of thousands of communities.
×
303<br>304<br>305
Programming thought experiment: stuck in a room with a PC without an OS. (self.programming)
submitted 16 years ago by vanjos72<br>673 comments<br>share<br>save<br>hide<br>report
loading...
sorted by: best<br>topnewcontroversialoldrandomq&alive (beta)
Want to add to the discussion?<br>Post a comment!<br>Create an account
you are viewing a single comment's thread.view the rest of the comments →
[–]kragensitaker 50 points51 points52 points 16 years ago* (2 children)<br>The Monitor
You'd need a minimal "monitor" to start with — something that would let you enter in some binary code on an input device and jump to it. Here's a C version that lets you enter code in octal:
typedef void (*function)();<br>char program[32];<br>int main() {<br>char *t = program;<br>unsigned i, n;<br>for (;;) {<br>for (i = 3; i; i--) {<br>n = getch() - '0';<br>if (n > 7) (*(function)program)();<br>*t = *t * 8 + n;<br>t++;
Translate that into 8086 machine code with a BIOS call for getch(), put it on the boot sector of the floppy, and you're golden. GCC compiles it into 12 instructions, plus the function prologue for main(). I think that would be 32 bytes in 16-bit mode. (Maybe the BIOS call would push it a couple of bytes over.) (I don't actually remember if the alt-keypad thing that lets you type arbitrary bytes is in the BIOS. If so, you could probably simplify the minimal monitor program above by removing the loop.)
Traditionally a monitor like this was first...