zComp - ASM simulator (VB9)

NightCrawler03X NightCrawler03X is offline Offline Jun 2nd, 2009, 3:49 pm |
0
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.

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
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.
Last edited by NightCrawler03X; Jun 2nd, 2009 at 4:01 pm.
Quick reply to this message  
Attached Files
File Type: zip zcomp4_wip1.zip (132.6 KB, 0 views)
0
NightCrawler03X NightCrawler03X is offline Offline | Jun 2nd, 2009
New 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)
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)
..
..
Last edited by NightCrawler03X; Jun 2nd, 2009 at 7:44 pm.
Attached Files
File Type: zip zcomp4_wip2.zip (139.6 KB, 1 views)
Quick reply to this message  
0
NightCrawler03X NightCrawler03X is offline Offline | Jun 2nd, 2009
Messing around with the bitshift operators, here are two simple example programs (they will be included in the next WIP and all later versions):
  1. mov #1 255
  2. shl 255 #31
  3. cmp 255 #1
  4. sho 255
  5. chr #10
  6. bin 255
  7. chr #10
  8. slp #100
  9. shr 255 #1
  10. bne 11
  11. jmp #13
  12. clr
  13. jmp #2
  14. chr #10
  15. chr #80
  16. chr #82
  17. chr #69
  18. chr #83
  19. chr #83
  20. chr #32
  21. chr #65
  22. chr #32
  23. chr #75
  24. chr #69
  25. chr #89
  26. chr #32
  27. chr #84
  28. chr #79
  29. chr #32
  30. chr #67
  31. chr #79
  32. chr #78
  33. chr #84
  34. chr #73
  35. chr #78
  36. chr #85
  37. chr #69
  38. key
  39. rts
The second one:
  1. mov #1 255
  2. clr
  3. sho 255
  4. chr #10
  5. bin 255
  6. cmp 255 #4294967295
  7. bne 8
  8. jmp #12
  9. shl 255 #1
  10. add #1 255
  11. slp #400
  12. jmp #1
  13. chr #10
  14. chr #80
  15. chr #82
  16. chr #69
  17. chr #83
  18. chr #83
  19. chr #32
  20. chr #65
  21. chr #32
  22. chr #75
  23. chr #69
  24. chr #89
  25. chr #32
  26. chr #84
  27. chr #79
  28. chr #32
  29. chr #67
  30. chr #79
  31. chr #78
  32. chr #84
  33. chr #73
  34. chr #78
  35. chr #85
  36. chr #69
  37. key
  38. rts
Enjoy.
Last edited by NightCrawler03X; Jun 2nd, 2009 at 8:50 pm.
Quick reply to this message  
0
NightCrawler03X NightCrawler03X is offline Offline | Jun 6th, 2009
New WIP (haven't updated here in a few days):
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
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
..
..
Attached Files
File Type: zip zcomp4_wip3.zip (144.6 KB, 0 views)
Quick reply to this message  
0
NightCrawler03X NightCrawler03X is offline Offline | Jun 6th, 2009
New WIP (slight improvement over the last one):
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
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
..
..
Attached Files
File Type: zip zcomp4_wip4.zip (146.2 KB, 0 views)
Quick reply to this message  
 

Message:


Similar Threads
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC