Building the binary instruction
The next step in the assembly process is to generate the appropriate binary pattern for each instruction. In this section, we show how the components of an instruction are put together to create a binary value that can later be executed by the computer.
Note that the code in this section describes some of the instruction processing involved in analyzing instructions. The actual simulator differs in minor details, although the principles are the same.
We first have to extract the mnemonic, convert it into binary, then extract the register numbers (where appropriate), and finally, insert the 16-bit literal. Moreover, because the assembler is in text form, we have to be able to deal with literals that are symbolic (i.e., they are names rather than numbers), decimal, negative, binary, or hexadecimal; that is, we have to handle instructions of the following form:
LDRL r0,24 &...