SECTION III - ASSEMBLING AND RUNNING AN 8051 PROGRAM

SECTION III - ASSEMBLING AND RUNNING AN 8051 PROGRAM:

Upto now we have created so many sample assembly language programs in previous Section-I and Section-II of this chapter. Now the question is that, how it is created, assembled and made ready to run?. The step to create an executable assembly language program. The steps to assembled an assembly language program is given below:

Steps to create a Assembly Language Program:

EDITOR ---->   ASSEMBLER ---->   LINKER ---->   OBJECT TO HEX PROGRAM

[ myfile.asm ]  [ myfile.lst ]+[ myfile.obj ]  [myfile.abs]    [ myfile.hex ]

  1. Editor Program: The first step is to use an editor to type in a program in assembly language instructions. Excellent editors that are available are word processors and widely used editor is the 'Note Pad' or 'Word Pad' in windows, which comes with all Microsoft Operating systems. The editor must be able to produce an ASCII file. The source file has the extension "asm" or "src" depending on which assembler is using. The "asm" extention  for the source file is used by an assembler in the next step # 2.
  2. Assembler Program: The "asm" source file containing the program code created in step #1 is fed to an 8051 assembler. The assembler converts the instructions into machine code. The assembler will produce an object file and a list file. The extension for the object file is "obj" and the extension for the list file is "lst".
  3. Linker Program: Third step required by assemblers is linking. The link program takes one or more object files and produces an absolute file with the extension "abs". This "abs" file is used by 8051 trainers that have a monitor program.
  4. Object to 'HEX' Convertor: The "abs" file is fed into a program called 'Object to HEX convertor' which creates a file with extension "hex". This "hex" file is ready to burn into ROM. This program comes with all 8051 assemblers. Recent Windows-based assemblers combine steps 2 through 4 in one step.

What is List File "lst" in Assembly language ?

The "lst" file is optional, but very useful to the programmer. The list file lists all the opcodes and addresses as well as errors that the assembler detected. Many assemblers assume that the list file is not wanted unless you indicate that you want to produce it. The list file can be accessed by an editor such as Note Pad and Word Pad. The programmer uses that list file to find syntax errors. After fixing all the errors indicated in the list file that the "obj" file is ready to be input to the linker program.

Example List File "lst" :

1 0000               ORG 0H                  ;Start at origin 0

2 0000   7D25  MOV R5,#24H         ;Load 25H into R5

3 0002   7F34   MOV R7,#34H         ;Load 34H into R7

4 0004   7400   MOV A,#0               ;Load 0 into A

5 0006   2D      ADD A,R5               ;Add contents of R5 to A,A=A+R5

6 0007   2F       ADD A,R7               ;Add contents of R7 to A,A=A+R7

7 0008   2412   ADD A,#12H           ;Add to accumulator value 12H

8 000A   80FE   HERE:SJMP HERE    ;Stay in this loop

9 000C             END                      ;End of asm source file

What is "asm" and "obj" files in Assembly Language?

The "asm" file is also called source file. Some assemblers require this file and have the "src" extension. This file is created with an editor such as Note pad and Word Pad. The 8052 assembler converts the asm file of assembly language instruction into machine language and provides the object file "obj". Beside creating the object file, the assembler also provides the "lst" list file.                                                      

 

More From Iamtechnical.com

Advertisement: