|
| 23 Dec 2013 03:49 PM |
I made a gui that consists of: -A text output (80x25) -A text input where you can type something and press a button to feed it in
The machine itself consists of: -64k units of memory (i use lua numbers for units) -A table of streams (which i can, using instructions, read number by number) Each stream is identified by a number -A table of instructions which translates a number into a function to be ran. The functions then read the data after the OPcode and do some operations.
How it works: 1. I write stuff to input and press enter. 2. The "hardware" (the lua code) adds the characters of the input to stream 0 as numbers (using string.byte) 3. The code (existing as instructions within the memory space) executes continuously in a loop, reading the input stream, and if there is something, it outputs it, and if not, it outputs "L" instead. (this is done with jumps and conditional jumps) 4. The hardware reads the output stream (numbered 1) character by character and adds it to the console output.
So itll spam "L" until i feed something in, in which case it spams "L" with whatever i fed in mixed in (because the feeding process waits a bit between each character)
Currently got around 20 instructions. Programming currently happens by filling in a hard coded "bootcode" table with numbers that represent the machine code. Here is the code described above: local bootCode={ 10, 2, 0, 0, --Read input to register 2 2, 4*4, 2, 0, --Jump over 4 instructions if input not 0 12, 3, string.byte("L"),0, --Write "L" to register 3 9, 3, 1, 0, --output register 3 1, 2*4, 0, 0, --Jump over the following 9, 2, 1, 0, --output register 2 20, bootsection, 0, 0 --loop } I have fixed instruction length at 4 units for simplicity (the 0's above are mostly meaningless). Registers are just memory addresses, i reserved some from the beginning of the memory space so i can use the memory space itself for eg. a stack (which i dont currently have).
TODO: -Program some actually useful boot code: *Support for multiple programs, where a block of memory is reserved for a program, and the program is loaded from a stream into this space and then executed. *Add subroutines to bootcode eg: ***Return control to bootcode so it can do task switching or something ***IO operations etc.
-Create assembly compiler in machine code somehow. Needs to have subroutines. Dont want to write machine code anymore. *Create it in lua first and then use it to make a compiler to be ran on the machine itself
-More IO: *Convert screen into pixel one instead of text one. Write graphics driver which can draw letters. Screen will be small and take a minute to update. *Use data persistence to create a file system such that you can save your creations/data *Create internet (a stream to allow sending packets to some "IP" address) *Add mouse input lel
-Move output screen into a surfacegui so it cooler
watdo dont worry im not going to do any of these because ill get bored. ill upload it uncopylocked in muh place. |
|
|
| Report Abuse |
|
|
| |
|
|
| 23 Dec 2013 04:56 PM |
| I would suggest going with a RISC architecture next time. Sure, having lots of opcodes is useful, if you are programming in assembly. Otherwise, it is almost always a better idea to have 8, 4 or 2 opcodes. Or you could go with subleq, making it 1 instruction - all data, no wasted space from opcodes :p. |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2013 10:08 PM |
SO UNCOOL, I WAS GOING TO MAKE ONE FIRST. UGH!
EOS db 0x00 ;End of String Marker |
|
|
| Report Abuse |
|
|
booing
|
  |
| Joined: 04 May 2009 |
| Total Posts: 6594 |
|
| |
|
|
| 23 Dec 2013 10:12 PM |
^ Phoenix is a better range strength.
EOS db 0x00 ;End of String Marker |
|
|
| Report Abuse |
|
|
booing
|
  |
| Joined: 04 May 2009 |
| Total Posts: 6594 |
|
|
| 23 Dec 2013 11:15 PM |
| Stfu LoL Plaer What is ,A Fenix |
|
|
| Report Abuse |
|
|
|
| 24 Dec 2013 03:52 AM |
| holy shizdy nizdy did you actually do this? :o |
|
|
| Report Abuse |
|
|
|
| 24 Dec 2013 06:30 AM |
| Its really simple. You just need an array of numbers and a table of number->func and a loop that reads the instruction pointer (which i set to be memory location 1) and runs the func that corresponds with the value at whatever the instruction pointer points to. The func then modifies memory in some way and moves the instruction pointer to the next instruction. |
|
|
| Report Abuse |
|
|
|
| 24 Dec 2013 08:08 AM |
| So you literally replicated assembler with Lua? Sounds cool! |
|
|
| Report Abuse |
|
|
|
| 24 Dec 2013 08:46 AM |
| This is an interesting VM, although, it would be a pain to implement on a chip :c |
|
|
| Report Abuse |
|
|
|
| 24 Dec 2013 08:51 AM |
| This sounds VERY intriguing, even though I'm a novice programmer. I'm going to track this thread. |
|
|
| Report Abuse |
|
|
|
| 24 Dec 2013 09:02 AM |
| You are free to write a proper kernel and an assembly compiler for it :< |
|
|
| Report Abuse |
|
|
|
| 24 Dec 2013 09:06 AM |
| Maybe when I am a more experienced programmer. It would be very interesting producing a game with a Virtual Machine template on here. |
|
|
| Report Abuse |
|
|