Assembly language is a very low level, human readable and programmable, language where each assembly language instruction corresponds to a computers machine code instruction. Assembly language programs translate directly into machine code instructions, with each assembly instruction translating into a single machine code instruction1.
After having chosen a basic address format for the architecture, the format of the assembly language, called an Instruction Set Architecture (ISA), is defined. The next step is to design the entire assembly language that will be translated and run on the CPU.
The following are the steps in design of the CPU.
- First, the assembly language is designed that can be used to write programs for this CPU. This language is tested by implementing simple programs in the assembly language.
- A machine code representation for the assembly language will be written. The CPU only has the ability to interpret information that is binary data, so the assembly language needs to be translated into binary data that will be understood by the CPU.
- The CPU is then designed to execute the machine code instructions.
This process of designing the language, creating the machine code for the language, and implementing the CPU is normally iterative, but the only final product of these steps will be included in this monograph.
The first step, the creation of the assembly language, is the topic of this chapter.
To create an assembly language there are three major constraints to the language that must be defined.
- The definition of data that will be dealt with in this CPU need to be defined. In higher level languages this would be types, like integer, float, or string. In a CPU, types do not exist. Instead the CPU is concerned with issues such as the size of a word in the computer, and how memory addresses will be used to retrieve data.
- A set of assembler directives to control the assembler program as it runs. Directives to define issues such as the type of memory being accessed (text or data), labels to specify addresses in the program, how to allocate and store program data, and how comments are defined.
- A complete set of assembler instructions must be defined.
The next section of this chapter will give some caveats to programmers coming from a higher level language about issues they should consider when programming in assembly language. The 3 sections after that will define the data used in the assembler, the assembler directives, and the assembler instructions.
1 Normally this one-to-one correspondence between assembly language instructions and machine code instructions is removed. Assembly languages will define pseudo instructions that are translated into multiple machine code instructions. These pseudo instructions are designed to make it easier to write programs in the assembly language. This monograph is designed to show the reader how the CPU works, and so every assembly language instruction will correspond to a single machine language instruction.