Question

In assembler or loader, which of the following statements are RELATIVE OR ABSOLUTE: 1) x - y 2) x...

in assembler or loader,

which of the following statements are RELATIVE OR ABSOLUTE:

1) x - y

2) x+y-z

3) x+7+v-w

here, x,y, z, v, w is symbol or label.

PLEASE GIVE PROPER JUSTIFICATION AND EXPLANATION FOR ANSWERS.

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

Expressions in assembler is one of the machine independent feature of assembler.

Expressions are simply combination of operands and operators . operand can be constant or symbols.

Expressions in assembler can be divided into two categories :

1: Absolute expressions

2: Relative expressions

         The significance of dividing expressions is at that time when program relocation is done, i.e. program is loaded at a new place in memory rather than its actual position , which is very common in the real world assembler.

1:ABSOLUTE EXPRESSION:

               These are the expression in which we need not change/ modify value of any operand at the time of program relocation .

Absolute expressions will give same result even if they are loaded at any memory address . We can also say that absolute expressions are not affected by relocation of program.

2:RELATIVE EXPRESSIONS:

               These are the expression in which we need to change/ modify values of operand at the time of program relocation .

Relative expressions give different result if they are loaded at different memory address . Hence, relative expressions are those expression which are affected by relocation of program.

   we can check an expression by simply putting some values in the place of symbols and calculate result, then change address of symbols and again calculate result , if both result are same then expression will be absolute otherwise expression will be relative.

now let us solve the problems given above:

1: x-y : absolute expression

reason:

let x=2000

y=1000

(note that 1000 and 2000 are address of x and y stored in symbol table)

x-y=1000

let program is relocated and x becomes 3000

now y will also be relocated . As we know relocation does not affect the size of program in the memory, y will be at same distance from x as it was prior to relocation, hence new position of y becomes 2000.

x=3000

y=2000

x-y=1000, which is same as prior to relocation,

hence the expression x-y is absolute expression.

(x-y will always give the difference between x and y which can not be changed even when relocation is done.)

2:x+y-z: relative expression

reason:

let x=0, y=1000,z=500 : x+y-z=500

suppose , after relocation: x=500 then, y=1500 and z=1000, now x+y-z=500+1500-1000=1000

(Result for same expression are different before and after relocation.)

hence the expression x+y-z is relative expression.

3:x+7+v-w: relative expression.

reason:

let x=0 v=200 w=50

result: x+7+v-w=157

suppose program is relocated and x becomes 100 :

v will becomec 300

w will become 150

result: x+7+v-w(7 is a constant hence it does not change) =257

as results are different , expression is needed to be modified if relocation is done, hence this expression is relative expression.

Add a comment
Know the answer?
Add Answer to:
In assembler or loader, which of the following statements are RELATIVE OR ABSOLUTE: 1) x - y 2) x...
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
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
ADVERTISEMENT