| | |
zComp - ASM simulator (VB9)
Hello, I would first like to note that I posted this on programmingforums some time ago; go there to catch up on all the progress I've made: http://www.programmingforums.org/post169607.html
zComp is a program that acts somewhat like a basic computer processor, with it's own instruction set. You write a program in what is very much like a real Assembly programming language, and then load that up in zComp, where it will execute those instructions just like a real processor.
Current instructions available...
- Logical bitwise operators (and, or, xor, not)
- loa (load the contents of a register, hardcoded value or ascii value of an inputted key into the accumulator)
- sto (store the contents of the accumulator into a general purpose register)
- cmp (compare two values and return true if equal else return false)... by extension, bne (jump to another instruction if cmp returned false)
- ovr (same as cmp, but for seeing if a value is greater than another value... equivalent of bne is "bno")
- lss (same as cmp, but for seeing if a value is lesser than another value... equivalent of bne is "bnl")
- chr (display an ascii character, e.g. "chr #65" would print "A" onto the screen)
- add (add the contents of a register or a hardcoded value onto the contents of another register)
- sub (like add, but for subtraction)
- mul (multiply the value in a register by a hardcoded value or the value in another register)
- div (like mul, but for division)
- sho (print the number stored in the accumulator, a general purpose register, or print a hardcoded value onto the screen)
- mov (store a hardcoded value of the value in a given register in a target register)
- jmp (jump to a new instruction dicated either by a hardcoded value, or contents of a register. Can also declare an isntruction to "jump back" to; e.g. jmp #89 #6 will jump to instruction 89, and then when you want to go back to #6, issue a "back" instruction)
- nop (no operation; used for comments... e.g. "nop this is a comment"
- clr (clear the contents of the screen such that the screen is blank))
- cln (clean out all registers and such (go back to the state the computer was in before running the program))
- key (await key input; used to pause the program)
- rts (halt execution and exit)
- slp (sleep for a given time, e.g. slp #1000 will make the program literally pause and do absolutely nothing for 1 second; can also say e.g. "slp 100" which will sleep for the time dictated by the value in register 100, or you can just say "slp" and it will sleep for the amount of time dictated by the value stored in the accumulator)
- skp (like jump, but instead of jumping to an "absolute", it skips a number of instructions. E.g. if you were on instruction 2 and you said "skp #6", the program would jump to instruction 8)
I'm looking at the x86 instruction set right now, for ideas on what kind of features to add next to zComp.
Anyway, without further ado, here is the project.
Contents of attached archive:
Included in the archive:
- Some sample programs (ASM I've written that will run on zComp)
- Full zComp4 Wip1 source code (open up the .sln file in the VB9 IDE)... go to the bin/Debug folder and you'll find a bunch of .asm files, those are the sample programs.
- zComp4 Wip1 executable (you'll need .NET 3.5); go to the bin/Release folder.
- writeKeys (input a string, output the ASM instructions to print those characters, and output the instructions to a file, where you can then copy/paste them into your ASM program. Is useful because printing stuff to the screen by chr'ing each character is time consuming). writeKeys used to be a seperate program, but I've recently merged it with zComp, so to access writeKeys just run zComp and you'll see on the menu a key option to run writeKeys.
The I've written license that this software falls under is included in the archive. Do read it before using this software so that you know your rights. I don't impose too many restrictions, and this software is both free and open source.
I do my best to check whether everything works properly, though I am only one person and I sometimes overlook certain details. If anyone finds any bugs in this software, do let me know. Thanks
..
..
Also, I've tested the bitwise operators I've added recently and I think they work properly, though I need someone else to verify for me. If anyone can verify for me, I would greatly appreciate it.
zComp is a program that acts somewhat like a basic computer processor, with it's own instruction set. You write a program in what is very much like a real Assembly programming language, and then load that up in zComp, where it will execute those instructions just like a real processor.
•
•
•
•
zComp version 4 WIP 1
bug fixes (relative to the regular release of zComp version 4):
-
what's new (relative to the regular release of zComp version 4):
- added some logical bitwise operators: and, or, xor, and not.
known bugs:
-
known limitations:
- it seems that cmp only compares the content of a register to a hardcoded value. It doesn't seem to support comparing
the content of a register to the content of another register. This is something I intend to fix
NOTE: This is based only on speculation of the code, not on actual testing
- Logical bitwise operators (and, or, xor, not)
- loa (load the contents of a register, hardcoded value or ascii value of an inputted key into the accumulator)
- sto (store the contents of the accumulator into a general purpose register)
- cmp (compare two values and return true if equal else return false)... by extension, bne (jump to another instruction if cmp returned false)
- ovr (same as cmp, but for seeing if a value is greater than another value... equivalent of bne is "bno")
- lss (same as cmp, but for seeing if a value is lesser than another value... equivalent of bne is "bnl")
- chr (display an ascii character, e.g. "chr #65" would print "A" onto the screen)
- add (add the contents of a register or a hardcoded value onto the contents of another register)
- sub (like add, but for subtraction)
- mul (multiply the value in a register by a hardcoded value or the value in another register)
- div (like mul, but for division)
- sho (print the number stored in the accumulator, a general purpose register, or print a hardcoded value onto the screen)
- mov (store a hardcoded value of the value in a given register in a target register)
- jmp (jump to a new instruction dicated either by a hardcoded value, or contents of a register. Can also declare an isntruction to "jump back" to; e.g. jmp #89 #6 will jump to instruction 89, and then when you want to go back to #6, issue a "back" instruction)
- nop (no operation; used for comments... e.g. "nop this is a comment"
- clr (clear the contents of the screen such that the screen is blank))
- cln (clean out all registers and such (go back to the state the computer was in before running the program))
- key (await key input; used to pause the program)
- rts (halt execution and exit)
- slp (sleep for a given time, e.g. slp #1000 will make the program literally pause and do absolutely nothing for 1 second; can also say e.g. "slp 100" which will sleep for the time dictated by the value in register 100, or you can just say "slp" and it will sleep for the amount of time dictated by the value stored in the accumulator)
- skp (like jump, but instead of jumping to an "absolute", it skips a number of instructions. E.g. if you were on instruction 2 and you said "skp #6", the program would jump to instruction 8)
I'm looking at the x86 instruction set right now, for ideas on what kind of features to add next to zComp.
Anyway, without further ado, here is the project.
Contents of attached archive:
Included in the archive:
- Some sample programs (ASM I've written that will run on zComp)
- Full zComp4 Wip1 source code (open up the .sln file in the VB9 IDE)... go to the bin/Debug folder and you'll find a bunch of .asm files, those are the sample programs.
- zComp4 Wip1 executable (you'll need .NET 3.5); go to the bin/Release folder.
- writeKeys (input a string, output the ASM instructions to print those characters, and output the instructions to a file, where you can then copy/paste them into your ASM program. Is useful because printing stuff to the screen by chr'ing each character is time consuming). writeKeys used to be a seperate program, but I've recently merged it with zComp, so to access writeKeys just run zComp and you'll see on the menu a key option to run writeKeys.
The I've written license that this software falls under is included in the archive. Do read it before using this software so that you know your rights. I don't impose too many restrictions, and this software is both free and open source.
I do my best to check whether everything works properly, though I am only one person and I sometimes overlook certain details. If anyone finds any bugs in this software, do let me know. Thanks
..
..
Also, I've tested the bitwise operators I've added recently and I think they work properly, though I need someone else to verify for me. If anyone can verify for me, I would greatly appreciate it.
Last edited by NightCrawler03X; Jun 2nd, 2009 at 4:01 pm.
•
•
•
•
0
New WIP.
I've tested "bin", "shl" and "shr" in the debugger and they seem to work as intended.
Included in attached archive:
- Sample ASM programs
- zComp 4 WIP 2 source code
- zComp 4 WIP 3 executable
- writeKeys (unchanged since last WIP)
..
..
•
•
•
•
zComp version 4 WIP 2
bug fixes (relative to the regular release of zComp version 4):
-
what's new (relative to the regular release of zComp version 4):
- added some logical bitwise operators: and, or, xor, and not.
- added "bin" to the instruction set - like "sho", but rather than display it's decimal value, it displays the equivalent binary value
- added "shl" and "shr" to the instruction set (bit-shift left and bit-shift right, respectively).
known bugs:
-
known limitations:
- it seems that cmp only compares the content of a register to a hardcoded value. It doesn't seem to support comparing
the content of a register to the content of another register. This is something I intend to fix
NOTE: This is based only on speculation of the code, not on actual testing
What I intend to work on:
Making it so that the logical bitwise operators can work with the accumulator (e.g. being able to not it, xor it with 00000000000000000000100101101111, etc)
Included in attached archive:
- Sample ASM programs
- zComp 4 WIP 2 source code
- zComp 4 WIP 3 executable
- writeKeys (unchanged since last WIP)
..
..
Last edited by NightCrawler03X; Jun 2nd, 2009 at 7:44 pm.
0
Messing around with the bitshift operators, here are two simple example programs (they will be included in the next WIP and all later versions):
The second one:
Enjoy.
ASM Syntax (Toggle Plain Text)
mov #1 255 shl 255 #31 cmp 255 #1 sho 255 chr #10 bin 255 chr #10 slp #100 shr 255 #1 bne 11 jmp #13 clr jmp #2 chr #10 chr #80 chr #82 chr #69 chr #83 chr #83 chr #32 chr #65 chr #32 chr #75 chr #69 chr #89 chr #32 chr #84 chr #79 chr #32 chr #67 chr #79 chr #78 chr #84 chr #73 chr #78 chr #85 chr #69 key rts
ASM Syntax (Toggle Plain Text)
mov #1 255 clr sho 255 chr #10 bin 255 cmp 255 #4294967295 bne 8 jmp #12 shl 255 #1 add #1 255 slp #400 jmp #1 chr #10 chr #80 chr #82 chr #69 chr #83 chr #83 chr #32 chr #65 chr #32 chr #75 chr #69 chr #89 chr #32 chr #84 chr #79 chr #32 chr #67 chr #79 chr #78 chr #84 chr #73 chr #78 chr #85 chr #69 key rts
Last edited by NightCrawler03X; Jun 2nd, 2009 at 8:50 pm.
0
New WIP (haven't updated here in a few days):
I haven't done much to the instruction set, but the code to load programs from file is much better now. It has a proper menu that lets you switch directory, show the files in that directory, show the specific .asm files in that directory (programs that will run on zcomp), and finally a load option which will bring up a list of the .asm files in that directory and a "menu" to load them... press 'a' to go up, 's' tp go down, 'space' to select the file, and 'esc' to escape to previous menu.
Included in attached archive:
- zComp 4 WIP 3 source code
- zComp 4 WIP 3 executable (you'll need .NET 3.5)
- writeKeys (same as ever)
- some sample programs
..
..
•
•
•
•
zComp version 4 WIP 3
bug fixes (relative to the regular release of zComp version 4):
- Fixed "rol", "ror", "shl" and "shr". They weren't storing the last shifted out bit into the carrier flag properly (this meant especially that rol and ror did not work at all). Hereby ammended.
what's new (relative to the regular release of zComp version 4):
- added some logical bitwise operators: and, or, xor, and not.
- added "bin" to the instruction set - like "sho", but rather than display it's decimal value, it displays the equivalent binary value
- added "shl" and "shr" to the instruction set (bit-shift left and bit-shift right, respectively).
- Made it so that the bitshift operators make use of a carrier-flag (store the last bit shifted out).
- Added "rol" and "ror" to the instruction set (bit-roll left and bit-roll right, respectively).
- New loading routine for programs. Better file handling, making things a bit nicer to use.
known bugs:
- I haven't observed this, only predicated based on inspection of the code:
the code to show a list of files will not account for over-lapping (when there are too many files to show on-screen)
I should make it so that the user can scroll down the screen (like how "ls -l | less" will work on Linux)
known limitations:
- it seems that cmp only compares the content of a register to a hardcoded value. It doesn't seem to support comparing
the content of a register to the content of another register. This is something I intend to fix
NOTE: This is based only on speculation of the code, not on actual testing
What I intend to work on:
- Making it so that the logical bitwise operators can work with the accumulator (e.g. being able to not it, xor it with 00000000000000000000100101101111, etc)
- Support the use of bin/hex all around zcomp. E.g. "add d#255 100" or "add b#11111111 100" or "add h#FF 100".
- Make it so that zComp remembers *everything* an ASM program outputs to the screen; this could prove to be VERY useful.
Todo
- Clean up the debugger
- Possibly clean up the new file handling code
Included in attached archive:
- zComp 4 WIP 3 source code
- zComp 4 WIP 3 executable (you'll need .NET 3.5)
- writeKeys (same as ever)
- some sample programs
..
..
0
New WIP (slight improvement over the last one):
This one fixes the limitation of the last one:
The amound of lines that can be printed to the console window is 50... 48 filenames could be shown. So what if there were more than 48 files to display? That's where WIP 3 failed, because you'd get over-lapping, making it quite difficult to select a file. Acting rather like "ls -l | less" would if you want to list all files in the directory on a Linux command line, zComp 4 WIP 4 accounts for if there are too many files (lines) to display in one go, letting you "scroll" through them so that you can still see every file available.
Included in the attached archive:
- zComp 4 WIP 4 source code
- zComp 4 WIP 4 executable (you'll need .NET 3.5)
- writeKeys (same as ever)
- Some sample programs
..
..
•
•
•
•
zComp version 4 WIP 4
bug fixes (relative to the regular release of zComp version 4):
- Fixed "rol", "ror", "shl" and "shr". They weren't storing the last shifted out bit into the carrier flag properly (this meant especially that rol and ror did not work at all). Hereby ammended.
what's new (relative to the regular release of zComp version 4):
- added some logical bitwise operators: and, or, xor, and not.
- added "bin" to the instruction set - like "sho", but rather than display it's decimal value, it displays the equivalent binary value
- added "shl" and "shr" to the instruction set (bit-shift left and bit-shift right, respectively).
- Made it so that the bitshift operators make use of a carrier-flag (store the last bit shifted out).
- Added "rol" and "ror" to the instruction set (bit-roll left and bit-roll right, respectively).
- New loading routine for programs. Better file handling, making things a bit nicer to use.
- The code for loading a programs from file now accounts for if there are more files to show
than can be shown on the screen... I account for "over lapping", where the menu for selecting a program
now acts somewhat like "ls -l | less" if you wanted to list a bunch of files on the command line when using a Linux OS
known bugs:
- The menu code for selecting a program from file is still a bit iffy when over-lapping. Fix that
known limitations:
- it seems that cmp only compares the content of a register to a hardcoded value. It doesn't seem to support comparing
the content of a register to the content of another register. This is something I intend to fix
NOTE: This is based only on speculation of the code, not on actual testing
What I intend to work on:
- Making it so that the logical bitwise operators can work with the accumulator (e.g. being able to not it, xor it with 00000000000000000000100101101111, etc)
- Support the use of bin/hex all around zcomp. E.g. "add d#255 100" or "add b#11111111 100" or "add h#FF 100".
- Make it so that zComp remembers *everything* an ASM program outputs to the screen; this could prove to be VERY useful.
Todo
- Clean up the debugger
- Possibly clean up the new file handling code
The amound of lines that can be printed to the console window is 50... 48 filenames could be shown. So what if there were more than 48 files to display? That's where WIP 3 failed, because you'd get over-lapping, making it quite difficult to select a file. Acting rather like "ls -l | less" would if you want to list all files in the directory on a Linux command line, zComp 4 WIP 4 accounts for if there are too many files (lines) to display in one go, letting you "scroll" through them so that you can still see every file available.
Included in the attached archive:
- zComp 4 WIP 4 source code
- zComp 4 WIP 4 executable (you'll need .NET 3.5)
- writeKeys (same as ever)
- Some sample programs
..
..
Similar Threads
- intergrating ASM to C++ (C++)
- Simulator Engineer - Portland, OR (Software Development Job Offers)
- Starting ASM (Assembly)
- My Sample ASM Code (Assembly)
- asm in C (C++)
| Thread Tools | Search this Thread |
.net advertisment applicationreengineering avoiddatacharges bbc blog botnet browser c# c++ captcha check coder coderisland crime cross development downloader email emeraldsoftwaregroup erp erpsystems evaluation examples feeds free freewebapp gre hack header http humanresources infosec intercage itconsulting java kittens law legal linux mailinglist mdd messagelabs.research mobile news onboarding opensource operatingsystem opinion outsourcing paperless pdf phishing photos php platform programming programmingforum project projects pumpanddump python rabihtawil realestatedirectory rolex samples screenshot selection software softwaredevelopment softwaresolutions spam spammer spammers spamming suggestion systemintegration testers tests timer toolbar trends twitter txt verbal viagra visual web website windows windows7 windows7review worldofwarcraft



