Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Advanced info on CPU Emulators Post 302532290 by Corona688 on Monday 20th of June 2011 12:50:07 PM
Old 06-20-2011
Quote:
Originally Posted by theKbStockpiler
Okay, I write code that mimics a CPU in that it has memory assigned to registers and flags and such to document the entire state of the CPU. I can't find a way around that I believe that for every target CPU instruction my emulator basically looks up a routine in a table and this routine changes the state of my phony CPU that exists in memory.
A table, or a giant switch() statement, or what have you. It just has to make a decision between a lot of instructions at once.
Quote:
Now I would have the phony CPU run the data and this would just be saved in memory. What would the process or application be called that puts this data in a certain form so the O.S would then run it and how would it do it?
[edit] I think I misunderstood your question.

I'm not sure I understand it, for that matter. Put the data in a format so the O.S can run it? Run data?

Are you asking how would you get useful data in/out of the emulator? Up to you I suppose. If you're expecting it to run programs meant for a different kind of computer, you'd probably need to emulate more hardware too, like DOSbox does.

DOSbox for example does what it says on the tin. It emulates a DOS machine well enough to run a good number of old games and applications. (On any system -- it doesn't depend on a real x86 cpu.) The list of hardware it emulates ends up being a bit daunting, including but probably not limited to:
  1. VGA controller, which displays the contents of a special hardware memory area on screen. In an emulator, the memory would be ordinary RAM like everything else. Routines independent of the CPU emulator would be responsible for transferring its contents into an ordinary graphical window where you can see them.
  2. Keyboard controller: DOS programs expect to communicate with the raw, old-fashioned keyboard controller, so DOSbox pretends to have one.
  3. PC speaker: To do proper PC speaker beeps, DOSbox pretends to have the old-fashioned IBM PC timer chip. This chip is necessary for lots of other things anyway, like the interrupts DOS and many games use to mark time.
  4. Soundblaster: It pretends to have one of these too. Or a Gravis Ultrasound.
  5. Adlib card: Mostly an OPL2 hardware synthesizer chip. An earlier soundcard that the Soundblaster cloned and expanded with raw digital sound.
  6. BIOS routines. In a real computer they're instructions stored in a special read-only area of memory. But since programs don't usually care what's in them as long as they work, DOSbox cheats a little, just triggering higher-level routines outside the emulated environment instead of doing all the work inside the emulated CPU. This includes some things like basic video mode changing, etc.
  7. Operating system routines. DOSbox gives you an actual DOS-like prompt and most of the DOS routines a real DOS environment would give to programs. This includes things like opening, reading, writing, deleting, closing files. DOSbox cheats. When the emulator causes a software interrupt that'd make a real CPU to jump to a location in memory, the emulator catches it, and does a real, native system call which ends up doing what the program asked. Not keeping all that DOS code in emulated memory also has the happy side effect of a DOS machine which can boot with nearly 640K free Smilie
  8. Comm ports and modems. In the days before widespread internet access most home telecommunication meant modems and COM ports. DOSbox can emulate having a dialup modem convincingly enough for some BBS software to work, but the pretend-modem is actually a TCP socket: When people connect to the socket, the DOS program is told the phone is ringing, and people can connect and talk with it with a terminal. Which is why we still have Tradewars 2001 in 2011 Smilie
DOSbox even has several different CPU emulators -- a fast simplified one, a slower 32-bit one with protected mode, etc -- and switches between them depending on what CPU features are needed.

So there's a lot more to emulating a whole computer than emulating its CPU.

Last edited by Corona688; 06-20-2011 at 02:17 PM..
This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

any emulators

iam new to unix , i would like to practice unix commands at home, can anyone help me to know if there are any emulators that i can download to practice or any trial versions that can be installed to practice. Regards dep (1 Reply)
Discussion started by: dep
1 Replies

2. UNIX for Dummies Questions & Answers

bus speed and CPU info

Hi, Is there a command I can use to find out how many CPU's and what type are on my server? (I was told to use cat /proc/cpuinfo) Also, how do I know what kind of bus speeds are on my server? Thanks in advance:) (3 Replies)
Discussion started by: ihot
3 Replies

3. HP-UX

cpu info

is there a single command or location from which one can get information like cpu Mhz,cpu cache...etc in HP UX:) (1 Reply)
Discussion started by: vijayca
1 Replies

4. Gentoo

top in batch mode, cpu info is wrong

well. the title says it all. im runing top in batch mode like this top -b -n1 > somefile but the cpu usage info is not correct. if i run top normally, the first second, i see the same wrong info, and then it corrects itself. i found only one small mention of it on this forum. with this link... (7 Replies)
Discussion started by: broli
7 Replies

5. AIX

How to access process and cpu info on AIX?

Hi, may be this is an AIX noob question: my current C++ application runs on Linux and is quite memory consuming. Therefore, the application writes a logfile after it has finished containing memory information, CPU information, information on the running other processes besides my application... (5 Replies)
Discussion started by: DarthVader77
5 Replies

6. HP-UX

CPU Info

Hi, I am going to buy a software that is licenced per CORE. I have a HPUX B1123 64 bit with 8 cpus. How can i know how many cores are in my machine ? Thanks (3 Replies)
Discussion started by: yoavbe
3 Replies

7. Shell Programming and Scripting

Generic command for CPU info

Dear all, Is there any generic command working on all Unix listing the CPU of a server? I found different command line per OS but I am looking for a more generic one. Thanks for your answer. (5 Replies)
Discussion started by: sgoiffon
5 Replies

8. Shell Programming and Scripting

Perl agent which calculates CPU info and more

Hello to everyone. This is my first post. I want to make one perl agent which calculate following things from Linux Server. Actually I want to pull all this information from 2 linux client and wants to display on web interface. First I want to calculate below details 1) CPU 2) MEMORY 3)... (6 Replies)
Discussion started by: sania.mirza
6 Replies

9. AIX

To get only the cpu info from the topas command terminal

To get only the cpu info from the topas command terminal. CPU User% Kern% Wait% Idle% Physc Entc ALL 2.3 4.4 0.0 93.3 0.07 7.7 I tried some thing like this but did not work topas << done grep "ALL" q done Can someone help me in this. (5 Replies)
Discussion started by: rpm120
5 Replies

10. UNIX for Dummies Questions & Answers

Best ways to get clear info about CPU and Memory

Hello all i did search the web and found allot of answers but im confused what are the best ways to get this info via Linux default commands 1. current Cpu Usage in Percent 2. current Memory Usage In Bytes 3. current Memory Available In Bytes Thanks! (2 Replies)
Discussion started by: umen
2 Replies
All times are GMT -4. The time now is 04:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy