Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASM
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
Edited 28-Jan-13 23:34pm
v2
Comments
Sergey Alexandrovich Kryukov at 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?
—SA
Member 9792935 at 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.
Sergey Alexandrovich Kryukov at 29-Jan-13 6:05am
   
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...
—SA
Member 9792935 at 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 at 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.
—SA
Member 9792935 at 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 at 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?
—SA
Member 9792935 at 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?
Sergey Alexandrovich Kryukov at 30-Jan-13 3:26am
   
How did I begin..? Do be serious... :-)
—SA
Member 9792935 at 30-Jan-13 3:51am
   
I figured, thanks for your help so far, I appreciate it.
Sergey Alexandrovich Kryukov at 30-Jan-13 12:01pm
   
You are welcome.
Wish you the best of luck,
—SA

1 solution

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

Solution 1

Do you ask for something similar like this[^]?
Cheers
Andi
  Permalink  
Comments
Member 9792935 at 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 at 29-Jan-13 11:22am
   
I don't know of any tutorial.
Andi
Member 9792935 at 29-Jan-13 23:07pm
   
Book? At any rate, thank you.
Andreas Gieriet at 30-Jan-13 0:35am
   
I don't know of any. Who would write a book about such a niche topic?
Andi
Member 9792935 at 30-Jan-13 3:22am
   
Thank you.
Andreas Gieriet at 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!
Cheers
Andi
Member 9792935 at 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
0 OriginalGriff 6,649
1 Sergey Alexandrovich Kryukov 6,270
2 CPallini 5,190
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 29 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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