0% found this document useful (0 votes)
3K views6 pages

Sheet 2 Solution

The document discusses memory segments, physical addressing, and addressing modes in microprocessors. It provides examples of calculating physical addresses for different memory segments and explains different addressing modes like register indirect, register relative, and base relative plus index. Various memory related concepts are explained like stack operations, converting addresses between logical and physical, and the ranges of different segments.

Uploaded by

Mohamed Alfarash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views6 pages

Sheet 2 Solution

The document discusses memory segments, physical addressing, and addressing modes in microprocessors. It provides examples of calculating physical addresses for different memory segments and explains different addressing modes like register indirect, register relative, and base relative plus index. Various memory related concepts are explained like stack operations, converting addresses between logical and physical, and the ranges of different segments.

Uploaded by

Mohamed Alfarash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1

University of Alexandria
Faculty of Engineering
Division of Communications & Electronics

Subject Name: Microprocessors Lecturer: Dr.Nayera Sadek


Academic Year: 2016 – 2017 Assistants: Khaled Essam

Third Year – Semester 1


SHEET 2 Memory Segments, Physical Addressing, and Addressing Modes

1-Review questions:

a) How much memory can be active at a given time in the 8086/8088


microprocessor?
There are four segments, each contain 64 KB, therefore, the active memory is equal to
4 x 64 KB = 256 KB, which is a quarter of the total available memory.

b) Which part of the memory address space is used to:


1-Store instruction of a program?
Code segment
2-Store the data used by the program?
Data segment
3-Store temporarily data?
Stack segment

2- Calculate the physical address for each of the following cases:


a) CS = 2000H, IP = 1000H
Address = CS x 10 + IP = 21000H
b) SS = 1234H, SP = 0100H
Address = SS x 10 + SP = 12440H
c) DS = 1000H, BX = 0010H
Address = DS x 10 + IP = 10010H
d) The memory address 0100:1234H
Address = Segment x 10 + Index = 02234H

3- Assume that BX = 4F56H, SP = 0100H and SS = 0200H. Explain what happens when
the PUSH BX is executed.
PUSH BX decrements the stack pointer (SP) by two then places BX at the two bytes
pointed by the new SP.
After execution:
SP = 0FEH
[020FE] = 56H
[020FF] = 4FH
2

4- Suppose that DS = 0200H, BX = 0200H and DI = 0300H. Determine the data memory
address accessed by each of the following instructions:

a) MOV AL, [2000H]


Direct addressing mode
Physical address = DS x 10 + 2000H = 04000H
b) MOV AL, [BX]
Register Indirect addressing mode
Physical address = DS x 10 + BX = 02200H
c) MOV [DI], AL
Register Indirect addressing mode
Physical address = DS x 10 + DI = 02300H

5-If CS=24F6H and IP=634AH, find:


a) The logical address
Logical address = 24F6:634A
b) The physical address
Physical address = 24F6 x 10 + 634A = 2B2AA
c) The lower range of the code segment
Lower range = 24F6 x 10 + 0 = 24F60H
d) The upper range of the code segment
Upper range = 24F6 x 10 + FFFF = 34F5FH

6-Assume memory locations of the following contents:DS:6826=48 and DS:6827=22.


Show the content of BX after the execution of the instruction MOV BX,[6826].
Direct addressing mode: the contents of address DS:6826 and DS:6827 will be moved to
the BX register because BX is a 2-byte register.
BX = 2248H

7-If SS=3500H and SP=FFFEH, calculate:


a) The physical address of the stack
Physical address = SS x 10 + SP = 35000 + FFFE = 44FFEH
b) The logical address of the stack
Logical address = 3500:FFFE
c) The lower range
Lower range = SS x 10 + 0 = 35000 + 0 = 35000H
d) The upper range
Lower range = SS x 10 + 0 = 35000 + FFFF = 44FFFH

8- If CS=FFFFH, find the physical address of the lower range and upper range of the
code segment.
Lower range = CS x 10 + 0 = FFFF0 + 0 = FFFF0H
Upper range = CS x 10 + FFFF = FFFF0 + FFFF = 0FFEFH
remember that the address is restricted to 20 bits only, the result of the previous addition is
10FFEFH but the 1 on the left is removed because it doesn't fit in the 20 bits. This is called
Wrap Around.
3

9- If SS=0C00H and SP=FF00H, how many words of data are currently held in the
stack if SP=0000H at the start of a certain program?
The stack has been decremented from 0000H to FF00H, therefore, we have stored a
number of
FFFF (first byte stored) – FF00 (last byte stored) + 1 (to count the subtracted byte) = 100H
bytes
100H = 256d
But we want to find the number of words; the number of words is 256/2 = 128 because
each word is two bytes.

10- State whether the following statements are true or false:


a- To make full use of stack, we initialize SP=0000H.
True; the stack grows down. For instance, if we initialize SP with 0004H then we have only
4 bytes of space to store the stack.
b- Code segment can be overlapped with Extra segment.
True; all segments are susceptible to overlapping.
c- Since there are four segments in the memory, the size of each one is calculated by
dividing the total memory by four.
False; the size is depends on the size of the upper and lower ranges. Since the upper and
lower ranges of the 8086 are 16 bits wide, then the size of any segment is 216 bytes = 64KB.
d- All registers can be saved on the stack.
True
e- The stack is a FIFO memory.
False; it's a LIFO memory.

11-If AX=3245H, BX=5632H, CX=672BH, CS=2000H, SI=62F4H, find the result of each
line of the following program :( the memory map is shown below)
a-MOV DS,AX
DS = AX
DS = 3245H
b-MOV SI,100H
SI = 0100H
c-MOV BX,04H
BX = 0004H
d-ADD AX, [SI]
AX = AX + [SI]
AX = 3245 + [DS x 10 + SI]
AX = 3245 + [3245 x 10 + 0100]
AX = 3245 + [32550]
AX = 3245 + 6A34 = 9C79

Memory location data


32557H 2DH
32556H 24H
32555H 3CH
32554H 8BH
32553H 79H
32552H 6FH
4

32551H 6AH
32550H 34H

12- If AX=0000, BX=0010, CX=0020, DX=3034, CS=1200, DS=1000, ES=1030, SS=1060,


BP=0040, SP=0400, DI=0060, SI=0050, IP=0100, Find:

a-Start and end of each segment.

CS:
start = 1200 x 10 + 0 = 12000
end = 12000 + FFFF = 21FFFH
Similarly
DS:
start = 10000, end = 1FFFFH
SS:
start = 10600, end = 205FFH
ES:
start = 10300, end = 202FFH

b-Physical address of top and bottom of stack.

Bottom = SS x 10 + FFFF = 10600 + FFFF = 205FFH

Note that the bottom of the stack is the address of the first byte stored in the stack, not
the lower range of the stack segment.

Top = SS x 10 + SP = 10600 + 0400 = 10A00H

c-The number of bytes are pushed on the stack.

As example 9:
Number = Bottom – Top + 1 = 205FF - 10A00 +1 = FC00H
FC00H = 64512 bytes

d-physical address of the next instruction.

The next instruction is pointed to by the instruction pointer


Physical address = CS x 10 + IP = 12000 + 0100 = 12100H

13- Convert the following decimal numbers to IEEE-754 short and long-form real
numbers:
a) 10
10 = 1010b = 1.01 x 23
Sign = 0, Mantissa = 01, Exponent = 3+ 127 = 130
0 1000 000 0100 0000 0000 0000 0000 000
b) - 11
- 11 = - 1011b = - 1.011 x 23
Sign = 1, Mantissa = 011, Exponent = 3+127 = 130
c) 101.125
5

101.125 = 01100101.001 = 01.100101001 x 26


Sign = 0, Mantissa = 100101001, Exponent = 6+127 = 133
d) – 65.0625
-65.0625 = - 01000001.0001 = - 01.0000010001 x 26
Sign = 1, Mantissa = 0000010001, Exponent = 6+127 = 133

14- Identify the addressing modes, the source, and the destination operands in the
following instructions:

a) MOV DL, BL
Mode: Register, Source: BL, Destination: DL
b) MOV AX, 00FFH
Mode: Immediate, Source: Immediate = 00FFH, Destination: AX
c) MOV [DI], AX
Mode: Register Indirect, Source: AX, Destination: DS:DI and DS:DI+1
d) MOV DI, [SI]
Mode: Register Indirect, Source: DS:SI and DS:DI+1, Destination: DI
e) MOV [BX] + XYZ, CX
Mode: Register Relative, Source: CX, Destination: DS:BX + XYZ and DS:BX + XYZ+ 1
f) MOV [DI] XYZ, AH
Mode: Register Relative, Source: AH, Destination: DS:DI + XYZ
g) MOV [BX][DI]XYZ, AL
Mode: Base Relative Plus Index, Source: AL, Destination: DS:BX + DI + XYZ

15- Identify the addressing modes, the source, and the destination operands in the
following instructions:
a)MOV AX,CX
Mode: Register, Source: CX, Destination: AX
b)MOV AX, 1234H
Mode: Immediate , Source: Immediate = 1234H, Destination: AX
c)MOV AL,’A’
Mode: Immediate , Source: Immediate = `A' , Destination: AL
d)MOV AL,[200H]
Mode: Direct , Source: DS:200 , Destination: AL
e)MOV [300H],BL
Mode: Direct, Source: BL, Destination: DS:300
f)MOV [SI],BX
Mode: Register Indirect , Source: BX, Destination: DS:SI and DS:SI+1
g)MOV [BX+10H],AX
Mode: Register Relative, Source: AX, Destination: DS:BX+10 and DS:BX+10+1
h)MOV CX,[BP]+98H
Mode: Register Relative, Source: SS:SP+98 and SS:SP+98+1, Destination: CX
i)MOV [BP][DI],AH
Mode: Base Plus Index, Source: AH, Destination: SS:BP+DI
j)MOV AX,[DI][SI]
Illegal (it's index plus index!)
k)MOV BX,[SI+20][BP]
Mode: Base Relative Plus Index, Source: SS:BP+SI+20 and SS:BP+SI+20+1,
Destination: BX
6

l)PUSH CX
Mode: Stack memory, Source: CX, Destination: SS:SP-2 and SS:SP-1
r)POP CS
Illegal

16) Given that: DS = 1000H, SS = 2000H, BP = 1000H, DI = 0100H and LABEL =


1234H. Determine the data memory address and the addressing modes for each of
the following instructions:

a) MOV AL, [BP][DI]+LABEL


Mode: Base Relative Plus Index
Address: SS:BP+DI+LABEL = 20000 + 1000 + +0100 + 1234 = 22334H
b) MOV CX, [DI]
Mode: Register Indirect
Address: DS:DI = 10000+0100 = 10100H and DS:DI+1 = 10101H
c) MOV DX, [BP]
Mode: Register Indirect
Address: SS:BP = 20000+1000 = 21000H and SS:BP+1 = 21001H

17) Given that: DS = 1100H, BX = 0200H, LIST = 0250H and SI = 0500H. Determine the
data memory addresses and the addressing modes for each of the following
instructions:

a) MOV LIST[SI], DX
Mode: Register Relative
Address: DS:SI+LIST = 11000+0500+0250 = 11750H and DS:SI+LIST+1 = 11751H
b) MOV BL, [BX][SI]+LIST
Mode Base Relative Plus Index
Address: DS:BX+SI+LIST =11000+0200+0500+0250 = 11950H
c) MOV BH, [BX]+LIST
Mode: Register Relative
Address: DS:BX+LIST = 11000+0200+0250 = 11450H

You might also like