Now I've always wondered how the base of a pc works and what RAM and GHz and all that stuff mean. The only thing I really know is hard drive space. So I decided to make a program that simulates a PC the way I think it works.
Now to explain my way of understanding the inner works of PC:I think that RAM is just a massive set of temporary variables that gets delete when the pc turns off.I think that the hard drive is just a massive set of non temporary variables.The GHz thing is how many assembly commands you run a second.The screen is run by a massive array.Now It has its own version of assembly and really bad syntax. I was wondering if anyone thinks there should be any other commands other then the ones listed below:0001 - IF - The if statement0002 - THEN - the then statement0003 - END - the end to the if statement0004 - SET VAR - sets a variable in the RAM to either a variable something returned or a number.0005 - RANDOM - returns random value 0000-99990006 - Screen Red- sets a pixels red value on the screen0007 - Screen Green - sets a pixels green value on the screen0008 - Screen Blue - sets a pixels blue value on the screen0009 - ADD VAR - Adds to a variable0010 - ADD Multiply - Multiplies variable0011 - KEY - key last pressed0012 - GOTO - goto a line in the code0013 - GETFILE - get a file/variable from the harddrive0014 - SETFILE - set a file/variable to the harddriveIn case you want to try it for your self:http://www.mediafire.com/?2v52c21q2ga2v1cSyntax is a bit strange.
You will be interested in this: 0x10c
It runs a version of assembly in your browser based upon the DCPU-16. It was made up by Notch.You can find more information here.While you have the general abstract overview correct - i.e. RAM is temporary, HDD is not - the rabbit hole actually goes much deeper than that:http://en.wikipedia.org/wiki/CPU_cachehttp://en.wikipedia.org/wiki/Paginghttp://en.wikipedia.org/wiki/Virtual_memoryIt is a lot to take in, but it is interesting to know your PC works. It is near impossible to truly understand exactly how all of your computer works, since each part is made up of many more interconnected parts; but you can attempt to understand how all the parts and systems work individually, and then appreciate how it can all come together as a whole.IF, THEN, END are kinda out of place, as assembly instructions don't ever need any context. The rest, while unrealistic, obey this. IF by itself makes no sense without END. You have GOTO, which is a more assembly-friendly control structure, however to emulate IF's you'll need some kind of GOTO-IF-EQUAL or something similar.
Cryus: 'or something similar'
But yeah, as Stevenup hinted, this is far from a realistic assembly language anyway. The RANDOM opcode is kinda funny. I could see some assembly language created at some point thinking it was a good idea. But generally, RANDOM means RNG, RNG means state, which would make it very inflexible as a single opcode.The file system is a simple array which doesn't get dlete once the program is turned off unlike RAM
This is an eery reminder of the way I used to think the internal system worked, until I got all those books about CPU design and computer architecture…
A lot of your 'opcodes' are actually higher-level constructs, which may or may not exist in HLA (High-level assembly), in some form or the other.An interesting thing to remember is that the CPU is a very simple beast: It can only work with numbers, and not in very complex ways. Most of the constructs you present would take many real opcodes to implement on a real system, and the control structure opcodes are weird.Hm, well at least I learnt something, I thought assembly was written in numbers alone…
Here is sample code from it:Write and wrong, in some ways. Assembly is a mnemonic code that is translated into numbers via an assembler. Different instructions have different lengths, and for each possible addressing mode there is a different number (But one mnemonic label).
Before I ramble, I suggest taking a look at this:http://www.plantation-productions.com/Webster/www.artofasm.com/DOS/index.htmlGrab the PDF and start reading.I was randomly looking for 0x10c stuff (not sure why), when I came across this:
http://0x10cwiki.com/wiki/Assembly_beginner%27s_guideIs this how assembly actually works?I don't know that much about ASM but from my previous experiences I'm pretty sure how it works.
Its fairly realistic but: