How ORG statement processed in two-pass assembly scheme, Computer Engineering

Assignment Help:

Can the operand expression in an ORG statement contains forward references? If so, outline how the statement can be processed in a two-pass assembly scheme.

ORG that is origin is an assembler directive that

  • Indirectly assign values to symbols
  • Reset the location counter to the given value-ORG value
  • Value can be: other symbol, constant or expression
  • No forward-reference

Assemblers scan the source program, producing machine instructions. Occasionally, the assembler reaches a reference to a variable that has not yet been explained. It is referred to as a forward reference problem. This is resolved in a two-pass assembler as given here:

In the first pass, the assembler simple firstly reads the source file, counting-up the number of locations as each instruction will take, and makes a symbol table in memory which lists all the defined variables cross-referenced to their connected memory address. In the second pass, the assembler substitute's opcodes for the mnemonics and names of variable are replaced by the memory locations acquired from the symbol table.

Consider the illustrated program

1216_ORG statement.png

On the first pass, the ORG statement puts the location counter to $800. Therefore the label N has the value $800, the label COLUMN has the value $802, the label M has the value $801 and the label ODD has the value $834. Hence the instruction CLR M will get three bytes, the instruction LDAB N will get three bytes and same forth. Likewise, we see that the first byte of instruction we observe that the first byte of instruction

LOOP:   LDDA 1, X+

IT will be at location $872. Therefore the symbolic address LOOP contain the value $872 and so on. In this continuing way, we come to

BPL     JUMP

Such program searches the array COLUMN seem for odd, negative, one-byte numbers, that then are stored in array ODD. The length of COLUMN is N and the length of ODD is M, that the program computes. We do not know the second byte of such instruction since we do not know the value of the address JUMP still. (It is termed as a forward reference, by using a label whose value is not still known.) Conversely, we can leave this second byte undetermined and proceed till we see that the machine code for DBNE is put in location $87f, therefore giving JUMP the value $87f.

If we continue our first pass downward then we allocate three bytes for DBNE B,LOQP.

We do not get this instruction's offset still, even if we already know the value of LOOP.

Scanning by the program again, that is the second pass, we can fill in each bytes, including those not found the first time through, for the instructions as BPL JUMP, BEQ JUMP and DBNE B,LOOP. Now, all object code can be produced.


Related Discussions:- How ORG statement processed in two-pass assembly scheme

Bi polar junction transistor, draw input and output charectoristics of BJT ...

draw input and output charectoristics of BJT and justify CE configuration provides large current amplification

What is rational robot, Rational Robot is a whole set of components for aut...

Rational Robot is a whole set of components for automating the testing of Microsoft Windows client/server and Internet applications. The major component of Robot lets you start

Explain topology method used in lan technology in detail, Explain topology ...

Explain topology method used in LAN technology in detail. LAN Topologies: Network topology is a physical schematic that shows interconnection of the various users. There are

Explain the term - rational rose and visio 2000 enterprise, Explain the ter...

Explain the term - Rational Rose and Visio 2000 Enterprise Rational Rose: IBM Rational RequisitePro is a powerful and easy-to-use tool for use case management and requirement

Explain difference between risc and cisc, RISC-Means Reduced Instruction Se...

RISC-Means Reduced Instruction Set Computer. A RISC system has decreased number of instructions and more significantly it is load store architecture were pipelining can be executed

Decision trees - artificial intelligence, Decision Trees - Artificial intel...

Decision Trees - Artificial intelligence: Suppose you just ever do four things at the weekend: go shopping, watch a film, play tennis or just stay inside.  What you do depends

Define the while loop, The while Loop The while loop repeats a statemen...

The while Loop The while loop repeats a statement until the test at the top proves false. As an example, here is a function to return the length of a string. int string_leng

What are the exceptions encountered for fp operation, What are the exceptio...

What are the exceptions encountered for FP operation? The exceptions encountered for FP operation are overflow, underflow. /0, inexact and invalid values.

Mplement a second-order low-pass filter using the finite dif, you will impl...

you will implement a second-order low-pass filter using the finite difference method. The finite difference method is a useful mathematical method that is used to numerically solve

Real life decoding, We have not considered the time element in our decoding...

We have not considered the time element in our decoding. An important time for decoding is the time from the address strobe (AS) to when the data is required in a read.   Time

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd