How does hardware run assembly? How was the first assembler written?

后端 未结 3 1920
暖寄归人
暖寄归人 2020-12-14 12:32

Having taken a course on compilers and making a rudimentary one by myself, i still have this lingering doubt about the first compiler.

From a high to low level, i se

3条回答
  •  醉酒成梦
    2020-12-14 13:14

    Actually I think you understand. First off the title question, how does hardware run assembly. Hardware runs on machine code or machine instructions or whatever term. As you have correctly described assembly is a representative of that machine code, and not always but is close to a one to one relationship one asm instruction to one machine instruction. These being bits, ones and zeros, the hardware can now perform the actions that the bits describe.

    Now how is the first assembler written? With pencil and paper. You typically write down the instruction in some sort of pseudo assembly as you may not have completely defined the language, and then you write down the bits based on the encoding, the same thing an assembler would do. Then using some mechanism you feed those bits into the computer and tell it to run.

    Eventually, naturally, this becomes tedious for larger programs so you decide to write a larger program that parses a language that is easier to write, then repeat that with more complicated languages and programs.

    Even today depending on the team and how they do things and the individual engineer testing the instruction decoder, etc. Writing machine code by hand still happens. Eventually the assembler is created and you switch to that and sometimes there is a higher level compiler and you switch to that for the bulk of the coding, but in the chip development world you still are very aware of and from time to time will modify the bits of an instruction at the machine code level.

提交回复
热议问题