A computer components & hardware forum. HardwareBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » HardwareBanter forum » Processors » Intel
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Emulating a processor



 
 
Thread Tools Display Modes
  #1  
Old November 22nd 05, 05:58 AM posted to comp.arch.embedded,comp.sys.intel,comp.sys.ibm.pc.hardware.chips,alt.os.development
external usenet poster
 
Posts: n/a
Default Emulating a processor

Hi all,

I'm interested to understand the processor architecture in depth. So i
decided on emulating the processor itself (as my project). The best one
to start would be 386.

So i wud require some documents which explains on how to emulate any
processor or devices. ( Apart from the Intel Architecture documents
available).
How to emulate a 386 processor. I want to kno how usually this is done.
I wonder how bochs has been developed so elegantly...the resource
they've used.

It wud be appreciable if someone can guide me on any documents or
reference books avaliable on Emulating processors and devices.

..
Wht are the resources I should have in hand to start up up this
project.

Thanks,
Gromer

  #2  
Old November 22nd 05, 06:29 AM posted to comp.arch.embedded,comp.sys.intel,comp.sys.ibm.pc.hardware.chips,alt.os.development
external usenet poster
 
Posts: n/a
Default Emulating a processor

why not take a look at the Bochs source code? Of course, it emulates
an entire PC system, not just the processor...

  #3  
Old November 22nd 05, 07:33 AM posted to comp.arch.embedded,comp.sys.intel,comp.sys.ibm.pc.hardware.chips,alt.os.development
external usenet poster
 
Posts: n/a
Default Emulating a processor

basically you have two choices:

full emulation: you read a byte from (emulated) ram and
interpret/execute it (use a huge switch-statement). then advance to the
next byte and interpret/execute it, ...


the virtualpc/qemu-with-accelerator/vmware/...-way: run the code as
ring3-process. catch every exception and emulate the thing that caused
the exception (i/o ports, mmu-stuff, ...)


but i suggest starting with something similar to dosbox
(http://dosbox.sf.net/). create a real-mode-only-emulator first. messing
around with page-tables and exceptions makes emulation quite difficult
to get right...

regards,
simon


Gromer wrote:
Hi all,

I'm interested to understand the processor architecture in depth. So i
decided on emulating the processor itself (as my project). The best one
to start would be 386.

So i wud require some documents which explains on how to emulate any
processor or devices. ( Apart from the Intel Architecture documents
available).
How to emulate a 386 processor. I want to kno how usually this is done.
I wonder how bochs has been developed so elegantly...the resource
they've used.

It wud be appreciable if someone can guide me on any documents or
reference books avaliable on Emulating processors and devices.

.
Wht are the resources I should have in hand to start up up this
project.

Thanks,
Gromer

  #4  
Old November 22nd 05, 12:11 PM posted to comp.arch.embedded,comp.sys.intel,comp.sys.ibm.pc.hardware.chips,alt.os.development
external usenet poster
 
Posts: n/a
Default Emulating a processor

[F'up2 cut down --- OP neglected doing it.]

In comp.arch.embedded Gromer wrote:

I'm interested to understand the processor architecture in depth. So
i decided on emulating the processor itself (as my project). The
best one to start would be 386.


I really wonder by what strange criteria the 386 could possibly come
out as "the best". Actually, the x86 is almost certainly the single
worst possible CPU line to do any theoretical work on. It's just too
plagued with silly exceptions due to its long history of compatibility
kept at almost any cost.

If you really want to learn something about CPU emulation, I'd
recommend Professor Knuth's work on the MIX and MMIX platforms ---
those are CPUs designed purely for educational purpose, and they only
ever existed as emulators, the original ones written by his Knuth-ness
in person.

--
Hans-Bernhard Broeker )
Even if all the snow were burnt, ashes would remain.
  #5  
Old November 22nd 05, 01:35 PM posted to comp.arch.embedded,comp.sys.intel,comp.sys.ibm.pc.hardware.chips,alt.os.development
external usenet poster
 
Posts: n/a
Default Emulating a processor

Hi Gromer

Why not to take an approach to vhdl.
Instead of emulating you can simulate and even synthesize.
If your aim is to better understand how a processor work this may give you a
deeper understanding.
Also there are numerous processor cores available as open source in vhdl,
mainly microcontrollers.


"Gromer" ha scritto nel messaggio
ups.com...
Hi all,

I'm interested to understand the processor architecture in depth. So i
decided on emulating the processor itself (as my project). The best one
to start would be 386.

So i wud require some documents which explains on how to emulate any
processor or devices. ( Apart from the Intel Architecture documents
available).
How to emulate a 386 processor. I want to kno how usually this is done.
I wonder how bochs has been developed so elegantly...the resource
they've used.

It wud be appreciable if someone can guide me on any documents or
reference books avaliable on Emulating processors and devices.

.
Wht are the resources I should have in hand to start up up this
project.

Thanks,
Gromer



  #6  
Old November 22nd 05, 03:30 PM posted to comp.arch.embedded,comp.sys.intel,comp.sys.ibm.pc.hardware.chips,alt.os.development
external usenet poster
 
Posts: n/a
Default Emulating a processor

["Followup-To:" nach comp.arch.embedded gesetzt.]

Simon Felix schrieb:

the virtualpc/qemu-with-accelerator/vmware/...-way: run the code as
ring3-process. catch every exception and emulate the thing that caused
the exception (i/o ports, mmu-stuff, ...)


VMWare does not work this way.

Markus
  #7  
Old November 22nd 05, 03:33 PM posted to comp.arch.embedded,comp.sys.intel,comp.sys.ibm.pc.hardware.chips,alt.os.development
external usenet poster
 
Posts: n/a
Default Emulating a processor

On 2005-11-22, Gromer wrote:

I'm interested to understand the processor architecture in depth. So i
decided on emulating the processor itself (as my project). The best one
to start would be 386.


Yikes. Since you've never written an emulator, I would have
recommended starting with a decent architecture. Something like
a PDP-11 or 6809 or Z80. The '386 is a really nasty bit of
work. It's 3 or 4 badly designed processors rolled into one.

So i wud require some documents which explains on how to
emulate any processor or devices. ( Apart from the Intel
Architecture documents available). How to emulate a 386
processor. I want to kno how usually this is done. I wonder
how bochs has been developed so elegantly...the resource
they've used.


Well, if you want to know how bochs as done, then look at the
bochs source code and documentation.

It wud be appreciable if someone can guide me on any documents or
reference books avaliable on Emulating processors and devices.

Wht are the resources I should have in hand to start up up this
project.


--
Grant Edwards grante Yow! Yow! Are we in the
at perfect mood?
visi.com
  #8  
Old November 22nd 05, 05:29 PM posted to comp.arch.embedded,comp.sys.intel,comp.sys.ibm.pc.hardware.chips,alt.os.development
external usenet poster
 
Posts: n/a
Default Emulating a processor

Grant Edwards wrote:

Yikes. Since you've never written an emulator, I would have
recommended starting with a decent architecture. Something like
a PDP-11 or 6809 or Z80. The '386 is a really nasty bit of
work. It's 3 or 4 badly designed processors rolled into one.


Agreed.

I wrote a Z80 simulator (I believe that the correct term for this thread's
topic is "simulator" rather than "emulator".) 20 years ao in 8088 assembler
on an 8 MHz AT&T 6300 that, at the time, had two 5.25" floppies and no hard
disk!

I used a rather straight forward (brute force?) method of allocating data
structures for the internal registers and look up tables for the op-codes.
The tables where used to jump to functions that "executed" the op-codes.
An Intel hex file decoder read program files into the simulated Z80 memory
space.

As usual, the hardest part was the user interface, especially the displays
of registers, and memory and I/O spaces. Interrupt generation was the
program's weak point and the thing I most planned to improve but never
got around to.

The greatest benefit of writing this program was the education concerning
the Z80's internals. I was writing embedded Z80 systems so this was a
good thing!

I had long thought that I had lost the source to this program but, in a
office renovation, I recently came across a disk that appears to contain
it. The trouble is that I no longer have a machine with a 5.25" floppy
drive. I might have to buy such a drive on eBay soon and see if the disk
is still readable!

--
================================================== ======================
Michael Kesti | "And like, one and one don't make
| two, one and one make one."
mrkesti at comcast dot net | - The Who, Bargain
  #9  
Old November 22nd 05, 05:59 PM posted to comp.arch.embedded,comp.sys.intel,comp.sys.ibm.pc.hardware.chips,alt.os.development
external usenet poster
 
Posts: n/a
Default Emulating a processor

In article , says...
Grant Edwards wrote:

Yikes. Since you've never written an emulator, I would have
recommended starting with a decent architecture. Something like
a PDP-11 or 6809 or Z80. The '386 is a really nasty bit of
work. It's 3 or 4 badly designed processors rolled into one.


Agreed.

I wrote a Z80 simulator (I believe that the correct term for this thread's
topic is "simulator" rather than "emulator".) 20 years ao in 8088 assembler
on an 8 MHz AT&T 6300 that, at the time, had two 5.25" floppies and no hard
disk!

I used a rather straight forward (brute force?) method of allocating data
structures for the internal registers and look up tables for the op-codes.
The tables where used to jump to functions that "executed" the op-codes.
An Intel hex file decoder read program files into the simulated Z80 memory
space.

As usual, the hardest part was the user interface, especially the displays
of registers, and memory and I/O spaces. Interrupt generation was the
program's weak point and the thing I most planned to improve but never
got around to.

The greatest benefit of writing this program was the education concerning
the Z80's internals. I was writing embedded Z80 systems so this was a
good thing!

I had long thought that I had lost the source to this program but, in a
office renovation, I recently came across a disk that appears to contain
it. The trouble is that I no longer have a machine with a 5.25" floppy
drive. I might have to buy such a drive on eBay soon and see if the disk
is still readable!


I did the same thing for the 68K processor. I also simulated a simple
serial port and a few interrupts. As you say, the most difficult part
was the user interface. My simulator was done on a Macintosh and worked
well enough that I used it when I taught an introductory course on
computer architecture. It turned out to be most useful in illustrating
what happens in memory when you use stack-based parameters for
subroutines. It beat the heck out of keeping track of the stack with
paper and pencil!

My simulator would interpret M68K assembly language in a text file--
stepping through the source code and showing effects on registers
and memory. It was cool at the time (mid 80's), but now you can
get a better simulator with just about every IDE designed to
do cross-compilation and debugging with an embedded processor.

Mark Borgerson


  #10  
Old November 22nd 05, 07:11 PM posted to comp.arch.embedded,comp.sys.intel,comp.sys.ibm.pc.hardware.chips,alt.os.development
external usenet poster
 
Posts: n/a
Default Emulating a processor

Mark Borgerson wrote:

I did the same thing for the 68K processor.


When I showed my simulator to the division engineering manager he asked
me if I could do a 68K version because we were about to embark on a 68K
project. I told him that I probably wouldn't finish it before the project's
final testing phase and that it probably wouldn't be all that useful even
if it was available sooner than that.

I also simulated a simple
serial port and a few interrupts. As you say, the most difficult part
was the user interface. My simulator was done on a Macintosh and worked
well enough that I used it when I taught an introductory course on
computer architecture. It turned out to be most useful in illustrating
what happens in memory when you use stack-based parameters for
subroutines. It beat the heck out of keeping track of the stack with
paper and pencil!


Yes, I can see that a classroom environment may be the best place for
serious use of such programs.

My simulator would interpret M68K assembly language in a text file--
stepping through the source code and showing effects on registers
and memory.


It didn't occur to me to have my simulator also be an assembler, but I
can see that this would be cool. How did you deal with forward references?

It was cool at the time (mid 80's), but now you can
get a better simulator with just about every IDE designed to
do cross-compilation and debugging with an embedded processor.


I've used plenty of IDE-based cross compilers and debuggers but don't
recall any of them being equipped with simlators. Can you provide some
examples of such?

--
================================================== ======================
Michael Kesti | "And like, one and one don't make
| two, one and one make one."
mrkesti at comcast dot net | - The Who, Bargain
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Emulating a processor Gromer General 25 December 1st 05 03:30 AM
speculation: Apple wants to make its own media-hub game console with a CELL-style processor from INTEL Ati Videocards 0 August 3rd 05 03:38 AM
speculation: Apple wants to make its own media-hub game console with a CELL-style processor from INTEL Nvidia Videocards 0 August 3rd 05 03:38 AM
Need sites, detailed explanation of Dual Channel signmeuptoo Asus Motherboards 2 June 1st 05 06:24 AM
pc problems after g card upgrade + sp2 ben reed Homebuilt PC's 9 November 30th 04 01:04 AM


All times are GMT +1. The time now is 01:39 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 HardwareBanter.
The comments are property of their posters.