1

Is there some information source or technical draft (something like RFC for networking) describing implementation of particular instructions (e.g. mov, jmp, je, jle, inc, ...) for Intel architecture?

Some general talk is on wikipedia but I'd like to know perfectly what's happening under the hood.

Thank you

xralf
  • 3,312
  • 45
  • 129
  • 200
  • 1
    http://www.scs.stanford.edu/nyu/04fa/lab/i386/c17.htm is the flavor of things you get from intel (not as good as other vendors documentation). you can look at http://github.com/dwelch67/pcemu_samples or any of the many x86 instruction set simulators which may or may not paint a more clear picture of how each instruction works. x86 has been microcoded to so "under the hood" varies from chip to chip and is likely not very well documented publicly. – old_timer Jan 23 '12 at 18:00
  • 2
    Dwelch is corrrect. Different series of processors have alternative methods in which they physically "flip bits", the instruction set you're using is actually yet-another-abstraction that gets converted to binary (you likely guessed that already), and then finally converted to the specific transistor methods. – Incognito Jan 23 '12 at 18:07
  • @dwelch Those are great links. If it's possible I'd like to go even deeper to the electric circuits (only to be able to imagine what's happening on the level of signals) – xralf Jan 23 '12 at 18:17
  • What exactly do you mean? The HDL level of these instructions? (wildly different between vendors, generations, and sometimes even between steppings) – harold Jan 23 '12 at 19:57
  • @harold The information that's in the accepted answer, other answers and comments is sufficient for me for some time. I'm beginner in assembly, so don't know much. – xralf Jan 23 '12 at 20:07
  • 1
    if you want to get deeper I have some other SO answers that do that in general for different things. Even better though go to opencores.org and find a core and play with it. Or xmos.com and get their developer package it has a signal level simulation where you can see at least some of what goes on (mostly just the outer layer, the external pins, their sim does keep the insides a secret). I also have my own toy/educational processor which you can sim and view http://github.com/lsasim. There may be some x86 clones you can inspect, maybe not – old_timer Jan 23 '12 at 22:39
  • 1
    if you want to get even lower than the logic signals into the gates them selves that is a whole other deal, just like a C program can be compiled for many different processors and operating systems and still work, logic signals can be implemented with many different libraries for many different targets from programmable devices cplds, fpgas to asics, and for each asic there is the foundary, the library, the technology, etc each builds different solutions at the transistor level. think of each of these as having a different assembly language to implement the same logic. – old_timer Jan 23 '12 at 22:41
  • 1
    also understand that even if you find something at opencores that mimics a known processor x86 or otherwise. this is not the same logic used by that vendor. if you gave a programming assignment to 20 people you might get as many as 20 different solutions that perform the specified task. Same here the open source author created one solution that if it were too close to the actual logic the company would probably shut it down. Intel has at least two teams leapfrogging different incarnations each time as well as amd making their own. there is no one x86 implementation under the hood – old_timer Jan 23 '12 at 22:44
  • @dwelch Thanks, it seems that these things are proprietary and closed, it's pity, for educational purposes this could be opened. The link for `lsasim` has 404 error. – xralf Jan 24 '12 at 09:16
  • sorry https://github.com/dwelch67/lsasim – old_timer Jan 24 '12 at 15:25
  • if you get a university professor or the EE or CS department head to champion something with a company that sells IP, perhaps ARM or MIPS, it is possible to setup a class/lab where the students could get access to these types of things. I have heard of universities having source code to windows for example, things like that. the simpler path would be to for example use the zpu or openrisc both have open cores and gnu toolchains, and I think can be put in an fpga, definitely simulated. – old_timer Jan 24 '12 at 15:28
  • the company I work for makes processors for a niche market, so I get to use the professional tools and dig into the guts and see the inner workings, and I am trying to find some way to share that experience with the outside world. every software developer i have exposed to watching their code execute in simulated logic, watching the busses read and write and registers being changed, etc have both enjoyed and benefited from it. there is an open source msp430 that you can do this with today, if you put the pieces together yourself. – old_timer Jan 24 '12 at 15:32
  • I would give up on the x86, you dont want to see the internals of todays x86, the only x86 internals i would find interesting would be the old school or an actually an 8088/86 clone. There is educational value in learning and teaching microcoding yes. The school i went to had a joint EE/CS class that was all about microcoding, we would look at a simple alu/processor and to perform certain tasks like an add we had to microcode the steps involved, mostly changing mux inputs to route the inputs, select the alu operation, and route the output. – old_timer Jan 24 '12 at 15:36
  • @dwelch Thanks a lot, there are lots of things for me to study yet. Usually when I learn something I want to see what's behind and behind etc. if I know more the principles, programming is more enjoyable and self-confident. – xralf Jan 24 '12 at 18:08

3 Answers3

2

They are generally implemented with micro-code, you can read up on that here, it mostly depends on the type of processors you are looking into (embedded, multi-core, power saving etc), Intel has some architecture design details here (the rest of the manuals also have various more minor details).

Its a bit old school now, but you should also find this helpful and interesting, it details the in depth design of the Pentium 4 series of processors, including instruction set implementation.

Necrolis
  • 25,836
  • 3
  • 63
  • 101
  • Yes, this is what I'm looking for. But is there deeper level than microcode (the physical signals in electric circuits)? Every instruction is not necessary, few are sufficient to have feeling I can see deeper. – xralf Jan 23 '12 at 18:26
  • @xralf: sounds like you'd do better off over at EE: http://electronics.stackexchange.com/search?q=cpu+design they cover the hardware implementation of things like this. – Necrolis Jan 23 '12 at 18:35
  • Thank you, great tip, I can go deeper there. – xralf Jan 23 '12 at 18:45
1

The implementations of many (most?) instructions have changed substantially over time. You could look at (for one example) Agner Fog's web site for some information, but be aware that:

  1. a lot of it is at least partially guesswork
  2. some of it is clearly out of date
  3. Some of it varies between current processors (especially Intel vs. AMD).
Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
  • Could you please guide me to some particular implementation on that link? – xralf Jan 23 '12 at 18:27
  • @xralf: No, not exactly. Some pieces of it talk about implementation details, but if (for example) you want to know all the details of one specific implementation, you're probably out of luck. For full details of a specific implementation, you might look at [Zet](http://opencores.org/project,zet86), but unless you understand Verilog, you may find it heavy going -- and it's still a separate implementation from Intel's or AMD's. – Jerry Coffin Jan 23 '12 at 19:28
1

You can download the x86 manuals from Intel here.

user1118321
  • 25,567
  • 4
  • 55
  • 86
  • Could you tell me where do I find the implementation of `jle` instruction in that manual? I'm not sure now if it's what I'm looking for and contributes to understanding of how it works. – xralf Jan 23 '12 at 18:22
  • There are several places in those documents where the conditional jump instructions are defined and explained, and I'm not really sure what it is you're looking for, so it's hard for me to say. The basic description of the conditional jump instructions is in section 7.3.8.2, though there appear to be many other places where they are discussed (for example page 2014). If you search the document for "jump" you'll see what I mean. – user1118321 Jan 23 '12 at 18:31
  • Thank you, it's useful but I was waiting for something more readable (e.g. with some picture of circuits). Necrolis told me I can ask on electronics SE to get this information. This is good for me too, but only part of the story. – xralf Jan 23 '12 at 18:51
  • @xralf - The latest chips contain a billion transistors. I don't think they will tell us in detail how they assembled it! – Bo Persson Jan 23 '12 at 21:44