Note that there are some explanatory texts on larger screens.

plurals
  1. POHow does an assembler work/how is it written?
    text
    copied!<p>In one of my classes, we are leaning about computer architecture and programming from the ground up. That means we started with pMOS/nMOS circuits, moved on to logic gates, then used logic gates to make registers and combinational logic units, and then analyzed a small microprocessor architecture (LC-3, in the case of my class).</p> <p>The next thing we did was write programs in assembly, which is where I got a little confused.</p> <p>Take for example: <code>ADD R0, R1, R2</code> which should add the contents of registers 1 and 2 and store it in register 0. As a machine word (in the architecture we learned in class) this instruction would be <code>0001 000 001 000 010</code> and I understand, on some level, how that binary word is then converted into a voltage signal which sets the proper value in the various multiplexers and control units in the processor.</p> <p>My question is, how is <code>ADD R0, R1, R2</code> converted to <code>0001 000 001 000 010</code> by the assembler? To someone with my level of understanding, this process seems to be analogous to compiling a higher level language. However there can be no compiler here, since there is no language more basic than Assembly with which to write the compiler!</p> <p>To put it another way, how is a program written to assemble the assembly code if it cannot itself be written in assembly. Is it written directly in binary by some genius and then hard coded into to program memory of the processor? I'm having trouble imagining a practical way to write an assembler than can be directly executed by the microprocessor.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload