Symbolic name memory location frst 1000 scnd 1001

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

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 M START DATA AT 1000 SET ASIDE AN ADDRESS FOR FRST SET ASIDE AN ADDRESS FOR SCND SET ASIDE AN ADDRESS FOR ANSR CLA FRST ADD SCND STA ANSR HLT 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 ANSR. Symbolic name Memory location FRST 1000 SCND 1001 ANSR 1002 Figure 12.5. Mapping table set up by the...
View Full Document

This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online