This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ill write a simple assembly language program for adding two numbers and
storing the result. The program is shown in Figure 12.4. To get an idea of how
the assembler will convert this program into an equivalent machine language
program, let us follow its instructions one-by-one. Notice that the first five
instructions of the program are pseudo-instructions for telling the assembler what
to do. They are not part of the main program to add the two numbers.
The first instruction of the assembly language program tells the assembler that the
instructions for the ma program (to add two numbers) should start at memory
location 0000. Based on this directive, the assembler w load the first instruction
for the main program (which happens to be CLA FRST in this example) at memo
location 0000 and each following instruction will be loaded in the following address (that is, ADD SCND will loaded at location 0001, STA ANSR at location
0002, and HLT at location 0003).
START PROGRA AT 0000
AN ADDRESS FOR FRST
AN ADDRESS FOR SCND
AN ADDRESS FOR ANSR
Figure 12.4. A sample assembly language program for adding two numbers and
storing the result.
The second instruction of the assembly language program tells the assembler that
the data of the program should start at memory location 1000. The next three
instructions tell the assembler to set aside addresses for data items FRST, SCND
and ANSR. Based on these four directives, the assembler sets up a mapping table
somewhere in the computer memory, which looks something like the one shown
in Figure 12.5. That is, the assembler picks up the first free address in the data area
of the program, which is location 1000, and calls it FRST; it picks up the next free
address in the data area, which is location 1001, and calls it SCND; and finally it
picks up the next free address in the data area, which is location 1002, and calls it
Symbolic name Memory location FRST
Figure 12.5. Mapping table set up by the...
View Full Document
This document was uploaded on 04/07/2014.
- Spring '14