9 karma · joined April 15, 2022
The decision to differentiate procedures from labels was intentional, and taken due to some restrictions of our IR (which is not the best, issue is open to change that).
Also, the way to define procedure is this way (separate form labels), as I felt that might be a bit more familiar to newcomers to assembly, who are coming from other languages.
Call stack exists inside assembler due to the same reason, as in case someone accidentally bashes their stack , it would still not corrupt the whole code. Maybe we should do a better job at reporting this so users can know they have corrupted the stack, instead of silently ignoring.
The SP should be changing, it is probably a bug. Thanks for reporting, I'll try to take a look at it.
This was originally made primarily for our own use, so I can definitely understand that the choices we made for this is not everyone's cup of tea.
However, I would just like to reply to the points, in case anyone else is also facing the same things.
- DB indeed doesn't support setting multiple different values, and that is definitely a thing we should change when we update his. Alternatively you can set multiple bytes to a same value using `DB [value,count]`
- Yes, this is intentional. As this emulator is not a "true" 8086 emulator that can just start from any memory address, we need a start label, much similar to how C needs a main function.
- Again, intentional. DB is strictly for data storage, and the whole code is (internally) split into data section (at start) and code section (after data section). Thus you cannot define DB once you start the code section. And as said, start indicates entry point of code, so any DB instruction cannot have start label.
- NOP is not implemented, and is an open issue at the repo.
- DB can be used without a label. for example ``` db [7,5] DW 0x7857 start: mov byte[0], 5
``` is a valid and compiling code. In case you had any issues using DB without label, feel free to comment here, or open an issue on github.
- Yes, ret cannot be used outside procedures. This is again intentional. As this emulator was aimed at students and newcomers to assembly, we wanted to kind of safeguard from accidentally using ret outside of a procedure context. In real assembly, it will let you use ret anywhere, but this does not.
> Also the terms. "compiling" is the process that generates assembly from a higher language. "assembling" is the process of turning assembly into machine code.
You are very much correct on this one. However, in this particular case I would suggest use of 'compiling' is also correct. As noted, this is an emulator of 8086, and we use an string based IR generated from the input assembly code. (This is not the best choice in hind-sight and there is an open issue for changing this). In that sense, we are indeed "compiling" the assembly code you have given to an executable/runnable representation, which then the emulator (which is basically an interpreter in this case) can run.
That said, I do agree that in general, (not in particular context of this emulator) "compiling" is not suited.
---
All said, This might not be everyone's choice for emulator, and I am glad that you gave it a try. Thanks!
It is intentionally so basic, as we wanted to make sure that any user, including those who have never written any assembly code before , can get a gist of it at the start.
That said, the ` Step 1: Write your code in the editor ` might be a bit overkill :smile:
If you have any suggestions on how we can improve the tutorial so new-comers can find it useful, and at the same time, it is not annoying, we would be very happy to hear it in a github issue.
Thanks!
We would really like to hear your thoughts on how we can improve this in a github issue, and we don't have much idea on LLMs, so there is a lot of room for improvements.
In the meantime, you can check the instructions page which lists the information and syntax/usage for them https://yjdoc2.github.io/8086-emulator-web/help
Hope this helps!
This syntax is intentionally verbose, so anyone new to assembly wouldn't mistakenly store word when byte was intended.
You can also check the complete supported syntax here : https://yjdoc2.github.io/8086-emulator-web/help in data transfer, mov section.
Hope this helps!
When designing this, we never intended to have support for external chips, so instead we designed this to have the full 1 MB of memory.
Hope this helps!
A bit of background on this is : we made this when we were students ourselves, learning about 8086, and couldn't find a decent emulator to do some of our lab work (or at least couldn't find a decent one with nice linux support).
We decided to write this primarily for ourselves, and for anyone who want to have an introduction to writing assembly in a friendly environment. This has mistakes, some decisions that seemed good at that time, but are quite bad in hind-site, and you are welcome to open issues on the respective github repos (github.com/YJDoc2/8086-Emulator for the syntax and emulator stuff, github.com/YJDoc2/8086-Emulator-web for the web ui).
We are now busy with other stuff, so the development is not as active as when we initially made this ; however, we try to update and add features, try to do bug fixes, and welcome contributors as much as we can.
Hope this project makes some newcomer interested in amazing domain of assembly, low level systems and system programming!
As I explained it in another comment, this aims to make it easier and more approachable for learners to learn about hardware. I (personally) feel HDLs can be a bit scary, and as this is in a higher level language, you get its familiarity and still get to think about pins and their connections and stuff.
As you mentioned , this is indeed choose-your-difficulty library. You can make everything out of gates, or as I did in my CPU demo, expose pins for connections, but do the internal processing using if-else and loops etc. (https://yjdoc2.github.io/pcb-rs-examples/) This allows focusing on stuff like how caches are invalidated on jumps and how waiting on memory takes CPU cycles etc.
Currently this does not translate to something that can be targeted to directly h/w like VHDL etc does. But hopefully this will make subject of hardware and low level systems more approachable and easier to learn.
Thanks!
What this aims to is make writing and learning about hardware more approachable to newcomers or self-learners. This is still in a high level language (Rust) so you have some familiarity, but you still have to consider how to connect pins and stuff, so you can start thinking about h/w that way. This is in a way choose-your-own-difficulty, so you can write everything from basic gates, or as I have done in the CPU demo, you can define pins, but write the processing logic in high-level constructs such as if-else, loops etc. This makes it easier to focus (for the CPU eg) on showing stuff like cache invalidating and wait states for memory access.
Another thing is that this can be compiled to wasm, so you can make circuits and provide nice GUI like I have done for all my demo examples at https://yjdoc2.github.io/pcb-rs-examples/ . This way you can have interactive examples right in your browser which you can play with.
Again, yes, HDLs can do all of this, but I think they are a bit scary to approach, especially if you're learning this yourself / are a newcomer ; and I hope that pcb-rs will be a rung in the ladder making it a bit easier to learn about hardware and low level systems.
Hope this clarifies it a bit! Thanks!