Question

What are the contents of the symbol table during the first pass after all of the...

What are the contents of the symbol table during the first pass after all of the instructions up to and including location 3 have been processed?

The answer is : SYM1=1234, LAB2= $100, SYM3=$12C, LAB4=??, LOOP= $053

1. Can someone explain to me why LAB2 equal to $100 and what is $5B43DE?

2. why is LOOP $053 instead of $054?

What are the contents of the symbol table during t

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The label field is optional. A label is an identifier (or text string symbol). Labels are used extensively in programs to reduce reliance upon programmers remembering where data or code is located. A label can be used to refer to<

a memory location the value of a piece of data the address of a program, sub-routine, code portion etc.

The maximum length of a label differs between assemblers. Some accept up to 32 characters long, others only four characters. A label, when declared, is suffixed by a colon, and begins with a valid character (A..Z). Consider the following example.

         START: LDAA #24H

Here, the label START is equal to the address of the instruction LDAA #24H. The label is used in the program as a reference, eg,

         JMP START

This would result in the processor jumping to the location (address) associated with the label START, thus executing the instruction LDAA #24H immediately after the JMP instruction. When a label is referenced later on in the program, it is done so without the colon suffix.

An advantage of using labels is that inserting or re-arranging code statements do not necessitate re-working actual machine instructions. A simple re-assembly is all that is required. In hand-coding, such changes can take hours to perform.

Each instruction consists of an opcode and possible one or more operands. In the above instruction

         JMP START

the opcode is JMP and the operand is the address of the label START.

The opcode field contains a mnemonic. Opcode stands for operation code, ie, a machine code instruction. The opcode may also require additional information (operands). This additional information is separated from the opcode by using a space (or tab stop).

The operand field consists of additional information or data that the opcode requires. In certain types of addressing modes, the operand is used to specify

  • constants or labels
  • immediate data
  • data contained in another accumulator or register
  • an address

Examples of operands are

         TAB ; operand specified by opcode
         LDAA 0100H ; two byte operand
         LDAA START ; label operand
         LDAA #0FH ; immediate operand

The comment field is optional, and is used by the programmer to explain how the coded program works. Comments are preceded by a semi-colon. The assembler, when generating instructions from the source file, ignores all comments. Consider the following examples,

                         ; H means hexadecimal valuesORG
        0100H            ;This program starts at address 0100 hex
STATUS: DFB 23H          ;This byte is identified as STATUS, and is
                         ;initialized to a value of 23 hex
CODE:   LDAA STATUS      ;The label called CODE is identified as a
                         ;machine code instruction which loads the
                         ;A accumulator with the contents of the
                         ;memory location associated with the label
                         ;STATUS, ie, the value 23
        JMP CODE         ;Jump to the address associated with CODE

Note that the programmer does not need to worry about bit patterns, hex values, and the addresses of STATUS or CODE. The assembler, when fed the above program, will generate the correct code. The code output from the assembler will be,

        Memory location         Byte value
         0100                    23
         0101                    B6
         0102                    01
         0103                    00
         0104                    7E
         0105                    01
         0106                    01

        Location 0100 holds the value associated with the label STATUS
        Locations 0101 to 0103 perform the LDAA STATUS instruction
        Locations 0104 to 0106 perform the JMP CODE instruction

The statement ORG 0100H in the above program is not a machine code instruction. It is an instruction to the assembler, which instructs the assembler to generate the code to run at the designated origin address. Instructions to assemblers are called pseudo-ops. These are used for

  • reserving memory for data variables, arrays and structures
  • determining the start address of the program
  • determining the entry address of the program
  • initializing variable values

The assembler does not generate any machine code instructions for pseudo-ops or comments. Assemblers scan the source program, generating machine instructions. Sometimes, the assembler reaches a reference to a variable which has not yet been defined. This is referred to as a forward reference problem. The assembler can tackle this problem in a number of ways. It is resolved in a two pass assembler as follows,

On the first pass, the assembler simply reads the source file, counting up the number of locations that each instruction will take, and builds a symbol table in memory which lists all the defined variables cross-referenced to their associated memory address. On the second pass, the assembler substitutes opcodes for the mnemonics, and variable names are replaced by the memory locations obtained from the symbol table.

OPERATION OF A TWO-PASS ASSEMBLER
Consider the following source code program for a hypothetical computer. The program computes the so-called Fibonacci numbers, printing all such numbers up to that specified by LIMIT.

Line            Label   Operation       Operand 1       Operand 2
1                       COPY            ZERO            OLDER
2                       COPY            ONE             OLD
3                       READ            LIMIT
4                       WRITE           OLD
5               FRONT:  LOAD            OLDER
6                       ADD             OLD 
7                       STORE           NEW
8                       SUB             LIMIT
9                       BRPOS           FINAL
10                      WRITE           NEW
11                      COPY            OLD             OLDER
12                      COPY            NEW             OLD
13                      BR              FRONT
14              FINAL:  WRITE           LIMIT
15                      STOP
16              ZERO:   CONST           0
17              ONE     CONST           1
18              OLDER   SPACE
19              OLD     SPACE
20              NEW     SPACE
21              LIMIT   SPACE

The instruction set of the computer is as follows,

Operation Code                          Number of
Symbolic        Machine         Length  Operands        Action
ADD             02              2       1               ACC <- ACC + OPD1
BR              00              2       1               Branch to OPD1
BRPOS           01              2       1               Branch to OPD1 if ACC> 0
COPY            13              3       2               OPD2 <- OPD1
LOAD            03              2       1               ACC <- OPD1
READ            12              2       1               OPD1 <- input stream
STOP            11              1       0               Halt execution
STORE           07              2       1               OPD1 <- ACC
SUB             06              2       1               ACC <- (ACC - OPD1)
WRITE           08              2       1               output stream <- OPD1

The functions that the assembler will perform in translating the program are,

  1. replace symbolic addresses by numeric addresses
  2. replace symbolic operation codes by machine operation codes
  3. reserve storage for instructions and data
  4. translate constants into machine representation
Add a comment
Know the answer?
Add Answer to:
What are the contents of the symbol table during the first pass after all of the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Choose a symbol from either "The Gift of the Magi" and discuss what significance this symbol...

    Choose a symbol from either "The Gift of the Magi" and discuss what significance this symbol had to you as the reader (an example of this would be the combs Jim gave to Della and a discussion about a precious gift that you received or gave). Use text examples in this section. If someone were to write your life story, what symbol would be present and why?  How does this symbol represent you?   You can attach a picture of your symbol (an...

  • Franks’ family had a full table for Thanksgiving dinner, including aunts, great aunts, uncles and cousins...

    Franks’ family had a full table for Thanksgiving dinner, including aunts, great aunts, uncles and cousins he barely knew. Luckily, Frank’s favorite cousin, Colin, a thirty-five year old software engineer working for a toy company in an exotic overseas location, flew in just for Thanksgiving. Colin was happy to be home and was entertaining everyone with his stories of the amazing foods he had eaten over the past few months. Finally, Thanksgiving dinner was served: turkey, gravy, spinach casserole, sweet...

  • please answer this after reading the article What is the actual problem? What are the known...

    please answer this after reading the article What is the actual problem? What are the known facts? What decision is to be made? How the problem ought to be solved? What are the alternatives? What are your recommendations? New AI tools make BI smarter — and more useful Data science democratized: What used to take data scientists months to prepare may soon be put together in a few days by data-astute business users. By Maria Korolov, Contributing Writer, CIO |...

  • QUESTIONS TO ANSWER: Prepare a table of all chemicals used with the structure and purpose of...

    QUESTIONS TO ANSWER: Prepare a table of all chemicals used with the structure and purpose of each. Calculate the theoretical yield by finding limiting reactant of the experiment by converting reactants to product (remember to show all calculations used) Calculate the percent yield using the limiting reactant Calculate the Rf for triphenylmethanol. If there are two dots, determine which one is triphenylmethanol.. ( I did not provide data. Please let me know how I Would do this if I did)...

  • I have to modify a server program and chat program to work as the following instructions...

    I have to modify a server program and chat program to work as the following instructions but I am completely clueless as to where to start. I'd appreciate any help on how to atleast get started. This must be done in java. Diffie-Hellman Two parties use a key agreement protocol to generate identical secret keys for encryption without ever having to transmit the secret key. The protocol works by both parties agreeing on a set of values (a) and (q)....

  • Can someone help me finish my table? all the inforamtion is there. molarity of HCL =0.5M g...

    can someone help me finish my table? all the inforamtion is there. molarity of HCL =0.5M grams of borax = 18.41g the Relationship between Thermodynamics and Equilibrium 21 Complete the data table for each temperature studied. Beaker Label 42 °C 45 °C 36 ° C 39 °C 33 °C 2EC 138℃-2°C| ーでー 46℃ Temperature reading (C) Absolute temperature (K) 1/T Final buret reading Initial buret reading Volume of HCI Moles of H+ Moles of B Os(OH)2 Molarity of B,Os(OH)2 306.230.2...

  • After Fran graduated with an undergraduate art degree in 2008, she decided to combine her knowledge...

    After Fran graduated with an undergraduate art degree in 2008, she decided to combine her knowledge and love of art with a second love—plants and flowers—toward developing a business. Her intent was to focus on a specialty niche in the flower shop business. She decided to concentrate her efforts on make-to-order special flower arrangements, like are typically found at banquets and weddings. Due to her talent and dedication to doing a good job, she was highly successful, and her business...

  • Most people fail to recognize the importance of networking and negotiating to their career success. People...

    Most people fail to recognize the importance of networking and negotiating to their career success. People who are good at networking tend to form better human relations with key individuals who can help them in advancing their professional careers. People who are good at negotiating have a better chance of getting what they truly desire. One’s ability to negotiate affects his or her compensation in the workplace. Negotiating Women, Inc. is a consulting company that focuses on women exclusively by...

  • Program 7 Arrays: building and sorting (100 points) Due: Friday, October 30 by 11:59 PM Overview...

    Program 7 Arrays: building and sorting (100 points) Due: Friday, October 30 by 11:59 PM Overview For this assignment, write a program that will calculate the quiz average for a student in the CSCI 240 course. The student's quiz information will be needed for later processing, so it will be stored in an array. For the assignment, declare one array that will hold a maximum of 12 integer elements (ie. the quiz scores). It is recommended that this program be...

  • internal project 1 anything helps! thank you!! Instructions: Study the case that starts on page 3...

    internal project 1 anything helps! thank you!! Instructions: Study the case that starts on page 3 carefully. Then write concise answers to the following questions regarding the internal control system of Duarf, Inc. Clearly label your responses with proper headings and subheadings. Be very specific and precise. Answers that appear to be beating around the bush will not get any credit. 1. What are the controls in place that under normal conditions should function well to prevent embezzlements or frauds?...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT