How does binary translate to hardware?

后端 未结 14 1010
长发绾君心
长发绾君心 2020-12-23 10:14

I understand how the code is compiled to assembly, and that assembly is a 1:1 replacement with binary codes. Can somebody help me understand how binary is conne

相关标签:
14条回答
  • 2020-12-23 11:14

    You may find this link of interest: http://www.eskimo.com/~ddf/Theory/Micro_Fund/Commands/AssyLnge.html

    In a short explanation, typically the application will be loaded to some area in memory and the processor will be given the start address, for the main or starting part.

    A processor can do two things, it can manipulate data and move data, so it will use special parts on the microprocessor called registers in order to store values or location that it will need.

    So, for an if statement, there is a command for whether two values are equal and where to go if they are not (branch if not equal). There will be some others, such as branch of equal or branch of greater than.

    These will be in the assembly.

    The commands are put into registers, with the appropriate arguments and it will be calculated on the next clock cycle.

    This is very simplified, but to a large extent, what you see in assembly is what the microprocessor will see.

    To go into more detail would probably be out of scope for StackOverflow.

    0 讨论(0)
  • 2020-12-23 11:16

    This seems like a 'how do computers work' question but you're not likely to be satisfied by the answers you get from Google.

    The details of how binary is 'connected' to the hardware is really the subject of computer design at a basic level. Some knowledge of hardware design is very useful for programmers, but not strictly necessary.

    The answers, so far, are 'Vastly simplified' because, well, they have to be.

    In general the explanations will only make sense to someone who understands the subject. I don't think there's much we can do about that.

    EDIT: perhaps the best we can say is that the bits in binary numbers (the zeroes and ones) correspond directly to the circuits in the hardware because circuits can be configured to 'store' a bit value, and those bits can be manipulated by the circuitry.

    That is, they can be stored, counted, added (and all the other basic arithmetic functions), output and input in groups forming whole numbers.

    Briefly, the bits in the binary numbers correspond to the transistors in the hardware. This, as the others have said, is an enormous simplification. It frequently takes more than one transistor to handle a bit, but that depends on the cleverness of the hardware designer.

    0 讨论(0)
提交回复
热议问题