? Assembler and Virtual Machine for a 16-bit URISC CPU ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Assembler and Virtual Machine for a 16-bit URISC CPU

Submitted
Updated
Author
amihart
Public Key
DY3X3DD
Min. Compat.
All
Rating
5 votes
Description The R313 is a (currently) imaginary URISC CPU created by me for educational purposes. URISC stands for "ultimate reduced instruction set", it is a computer with only one instruction. Since it only has one instruction, you do not even need to store the instruction in memory, only the operand of it. The R313 is based on the reverse-subtract and skip-on-borrow (RSSB) instruction (view the README for how this works). It has one operand and is Turing complete. This program contains two programs called "RASM" and "RVM". RASM is the assembler. Included is a "Hello, World!" assembly program to help you understand how it works. RVM is the virtual machine. It will run your code. Please note that I had designed this CPU architecture a long time ago for educational purposes. Coding for this CPU is very difficult and rather impractical. However the virtual machine and assembler that come with this are both fully documented to serve as a guide for assembler and emulation creation. This was originally written in C and then ported to SmileBASIC. You can check out the assembly "Hello, World!" code on PC here
Categories
Keywords
14 Comment(s) Krondelo Krondelo Awesome work, thanks for this! Now lets just hope I can actually understand it and learn a thing or two. ninjagnu ninjagnu Avatar Taboo I didn't change my avatar for 180 days Website Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Why not get rid of RSSB prefix before things? If all you need is the arguments? amihart amihart Looks nicer that way imo. snail_ snail_ Helper Received for being very helpful around SmileBASIC Source Achievements Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength First Day Joined on the very first day of SmileBASIC Source Website Why not use ' for comments like SB? It looks better in the editor. You could make it another option and leave in the "original" comment character for compatibility. 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Second Year My account is over 2 years old Website That's just an annoying thing to deal with. The code wouldn't be compatible with other versions of the assembler, and plus, basically every assembly language uses ; for comments. snail_ snail_ Helper Received for being very helpful around SmileBASIC Source Achievements Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength First Day Joined on the very first day of SmileBASIC Source Website I haven't looked too far into it, but I'm convinced with a few basic tweaks, you can implement 90% (or more) of an assembler in SB using just a COMMON DEF library. You'd be limited in features and syntax, I guess, but it's a possibility because many assembly languages are so simple. Using ' for comments is one step towards this. randomous randomous Head Admin Robot Hidden Easter Eggs Second Year My account is over 2 years old Website Drawing I like to draw! Hobbies Ah cool! I hope people learn stuff from this! ninjagnu ninjagnu Avatar Taboo I didn't change my avatar for 180 days Website Zelda Is Awesome! I love The Legend Of Zelda! Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength So basically rasm is a version of the MOVfuscator but in SB :P amihart amihart I've never heard of the MOVfuscator until now, but looking into it, they are definitely very different. The MOV instruction on an x86 machine just so happens to be Turing-complete in of itself. The MOVfuscator uses this to compile C code into native x86 code only using this single instruction. The differences are as follows:
  1. The MOVfuscator compiles code specifically to run on an x86 chip natively. It does not contain a virtual machine as it is intended to run on your actual hardware.
  2. The MOVfuscator uses "MOV" logic and not "RSSB" logic.
  3. The MOVfuscator compiles from C code while this currently only compiles from assembly code. I don't believe the MOVfuscator contains an assembler because it's meant to be assembled using a native assembler.
12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Second Year My account is over 2 years old Website I believe that the FIX16 function can be replaced with N<<16>>16. Additionally, single characters of a string can be accessed using square brackets rather than MID$. Also I think your sorting function could be written as something like: DIM LENS[LEN(STN$)] FOR I=0 TO LEN(STN$)-1 LENS[I]=LEN(STN$[I]) NEXT SORT LENS,STN$,STV 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Second Year My account is over 2 years old Website Oh, a few more things. SB has logical and/or operators (the standard && ||), and you can compare strings using < >= etc. amihart amihart Does using "&&" instead of "AND" have any effect on performance? 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Second Year My account is over 2 years old Website If the first value is false, it doesn't have to evaluate the second value. (And the opposite for ||) snail_ snail_ Helper Received for being very helpful around SmileBASIC Source Achievements Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength First Day Joined on the very first day of SmileBASIC Source Website It's just generally more sane to use the right operator for the job. Bitwise AND/OR have to do more work, but it's just more clear to use the logical/conditional operators to people reading your code. Two bonuses in one.