Click here to Skip to main content
13,596,178 members
Rate this:
Please Sign up or sign in to vote.
See more:
I need to build an assembly simulator for the x86 architecture.

I haven't been able to find any resources on the topic and I could use any help to set me on the right direction. I have basic understanding of assembly language and any further help on that part are appreciated, and any open source tools are welcomed too.

The outcome should be something like the Little Man Computer[^] or most likely MARS[^]

Thanks in advance.
Posted 28-Jan-13 15:24pm
Updated 28-Jan-13 23:34pm
Sergey Alexandrovich Kryukov 28-Jan-13 22:11pm
You can simulate a CPU, of course, but what is "Assembly simulator"? something that only simulates the work but does not assemble anything, or what?
29-Jan-13 5:36am
I'm not sure what do you mean however, I updated the question for examples. It should assemble the code entered and provide the assembled output with execution.
I got it, but "Assembly simulator" would be a misleading name for it.
OK, it's a big work; so it's not clear what help do you expect... It's not about any particular tools. This is pure programming...
29-Jan-13 6:32am
Well, where shall I start? I'm sure it's doable, I just need a start and be pointed to the right direction.
Sergey Alexandrovich Kryukov 29-Jan-13 23:30pm
Anyway... I would expect more maturity from your, if you want to get to this topic.
This approach is described in some books on system programming. I've read one of them, too long ago to remember. From the other hand, even though the book is based on existing emulator which is not described in its implementation, I more or less clearly understand how to design such thing. You need to do a pretty serious research; and finding literature it a part of it. If you hope to find a manual, you may be going a wrong way. I don't want to offend anyone, and there is nothing offensive in that, in essence, but manuals, even genial ones, in some sense, are the second-sort literature. You need to look for scientific literature on the topic. I am not even sure that manuals exist in this field. I, for example, would not probably take a job of writing such manual. People educated well enough to design and implement such simulator, usually don't need manuals. Can you see the point?
Sergey Alexandrovich Kryukov 29-Jan-13 12:45pm
Do you want to develop the code, or find something? If you need to develop, you should be way more independent. This is quite a serious work, with elements of research. You need to start with learning of the architecture of the CPU you want to simulate. If you want to create your own CPU (which is a traditional approach, creation of some "study" CPU, simplified), you need to start learning principles of CPU architecture.
How did I begin..? Do be serious... :-)
30-Jan-13 3:22am
I have been searching for some time now however I didn't come to find a specific result as I'm not sure what to search for, or lack to understand the relevance of what I find. You mentioned that you understand how to design such a thing, how did you begin to understand how to design them?
29-Jan-13 23:06pm
If there is existing code, then yes I'm probably going to use it, however I'll still need to understand it to modify it for my needs. This is a senior project in my computer science major, as such I have an understanding of computer architecture however we haven't studied something like this before, and I took it to learn something new in the process.
Sergey Alexandrovich Kryukov 30-Jan-13 12:01pm
You are welcome.
Wish you the best of luck,
30-Jan-13 3:51am
I figured, thanks for your help so far, I appreciate it.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Do you ask for something similar like this[^]?
Andreas Gieriet 29-Jan-13 11:22am
I don't know of any tutorial.
29-Jan-13 5:43am
Probably yes, however, I could use a tutorial or an approach on how to make it as I need to understand the code and how it functions for later modifications.
Andreas Gieriet 30-Jan-13 0:35am
I don't know of any. Who would write a book about such a niche topic?
30-Jan-13 3:22am
Thank you.
29-Jan-13 23:07pm
Book? At any rate, thank you.
Andreas Gieriet 30-Jan-13 3:31am
You are welcome.
BTW: independent of CPU simulation, if you face the situation where you want to simulate some behaviour, you need to create a *model* of the item to simulate and some *model* of the needed environment the item is embedded in.
To write a model, you need a good understanding of the "reality" that you want to model. I.e. for the CPU, you must understand the basics of instrunction set and how instructions are processed. For CPU architectures and how they are processed, there certainly are books and web resources available.
Get these data first. Then learn the principles of instructions (flow control, status, decisions, ALU operations, register set, addressing modi, etc.) and how they are processed (fetch, decode, execute = read/modify/write registers/memory, etc.).
Once you have a good enough understanding of the above, create a model that provides functions to control the above mentioned processing (Fetch, Decode, Execute), and provide Models for the environment (Memory, etc.). In the CPU model, provide functions for the instrunction decoding and execution (op-code decoding, addressing modi decoding, data access to registers/memory, etc.).
Good luck!
30-Jan-13 3:51am
Thanks again, I'll wait until the end of my research to see if I could by that time answer the question myself.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web04-2016 | 2.8.180621.3 | Last Updated 29 Jan 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100