Assembler and Addressing Mode 8051
Assembly language is the human language most closely tied to machine language. addressing mode 8051 It is usually written in instruction mnemonics. Once the program has been written in mnemonis, it is translated into machine code by a process known as assembly the program.
Assembly language programming requires the use of application programs, known as utilities or tools. Addressing mode It converts the assembly language programs into code memory bit charges. Assembly language programming is done by using a personal computer. The personal computer is used to speedily write and test the assembly language programs.
- The steps to create an executable Assembly language program are outlined as follows.
- First we use an editor to type the required program.
- Many excellent editors or word processors are available that can be used to create and/or edit the program. A widely used editor is the MS-DOS EDIT program (or Notepad in windows). The editor must be able to produce an ASCII file. For many assemblers, the source file has the extension “asm” or “src” depending on which assembler we are using.
- The “asm’ source file containing the program code is fed to an 8051 assembler.
- The assembler converts the instructions in to machine code. The assembler will produce an object file and a list file.
- The extension of object file is “obj”, while the extension for the list file is “Ist”.
Addressing Mode 8051
- Assember requires a third step called linking. The link programs take one or more object files and produce an absolute object file with the extensions “abs”.
- This abs file is used by 8051 trainers that have a monitor program.
- Next the ‘abs’ file is fed into a program called ‘OH’ (Object to hex converter) which creates a file with extension ‘hex’ that is ready to burn in to ROM.
- This program comes with all 8051 assemblers. Recent windows based assemblers combine steps 2 through 4 into one step.
The ‘asm’ file is called the source file. The 8051 assembler converts the asm file’s Assembly language instructions into machine language and provides obj (object) file. In addition to creating the object file, the assembler also produces the “Ist” file (list file)
The “Ist” file is very useful to the programmer because it lists all the opcodes and addresses as well as errors that the assembler detected.
Structure of assembly language – Addressing Mode 8051
An assembly language instruction consists of a mnemonic, optionally followed by one or two operands. The operands are the data items being manipulated and the mnemonics are the commands to the CPU, telling it what to do with those items.
An assembly language instruction consists of four fields. [label :] mnemonic [operands] [; comment]
Brackets indicate that a fleld is optional, and not all lines have them.
Label field – ltano The label field allows the program to refer to a line of code by name. The label field cannot exceed a certain number of characters. The label field occurs at the first field of a source statement.
A symbol character as the first character indicates that the line has a label. Symbol characters are the upper or lower case letters a – z, digits 0 – 9, and the special characters of period ( . ), dollar sign ($), and underscore ( _ ).
Symbols consists of one to 15 characters, the first of which must be alphabetic or the special character period ( . ) or underscore ( _ ). All character are significant and upper and lower case letters are distinct. A symbol may occur only once in the label field.
Mnemonic or Operation field – 8051
The operation field occurs after the label field, and must be preceded by atleast one white space character. The operation field must contain a legal op-code mnemonic or an assembler directive. The operand field specifies what type of operation the instruction can perform. The assembly language mnemonic (instruction) and operand fields together performs the read work of the program.
The operand field’s interpretation is dependent on the contents of the operation field. The operand field, if required, must follow the operation field, and must be preceded by atleast one white-space character. Operand field specifies either the address or data. The operand field may contain a symbol, an expression or a combination of symbols and expressions separated by commas. There can be no white spaces in the operand field.
The assembly language mnemonic (instruction) and operand(s) fields together perform the real work of the program.
Comment field – Addressing Mode
The last field of an assembler source statement is the comment field. The operand field comment field is separated from the (or from required) by the operation field if no operand is atleast one white space character.
The comment field begins with a semicolon comment indicator Comments are optional, it is recommended that they be used to describe the program and make it easier for someone else to read and understand.
An assembler is basically a translator(software). It translates the assembly language program into machine language program.
Assembler ASM51. ASM51 runs on PCXT/AT, and generates hexa codes for 8051 family microcontrollers.
The microcontroller 8051 provides five addressing modes
- Immediate addressing mode
- Direct addressing
- Indirect addressing
- Register addressing
- Index addressing
The hexa codes generated by the assembler ASM51 may be downloaded to the microcontroller kits by using upload/download utilities supplied along with the kit.
Assembler Directives (Psedueo Instructions)
Assembler directive contains some instructions, which are not executable by the microcontroller. Assembler directives are used to define symbols, reserve memory spaces, store values in program memory, set the current segment location counter, identify the end of source file etc., Only one directive. per line is allowed in programs.