Sie sind auf Seite 1von 9

CAMP Tutorial Sheet I-1

Department of Electrical Engineering, IIT Bombay


EE309 Computer Organization, Architecture and
Microprocessors: Tutorial Sheet I
Basic Computer Organization

General Outline
• Components of a Basic Computer - Computational Unit, Storage. Regis-
ters and Memory

• What does the instruction set of a machine depend on ?


• The Control Unit, ALU, I/O, and registers
• The Stack

• Instruction Formats
• Addressing Modes
• Memory Organization. Virtual Memory

• Interrupts, I/O: Peripheral-mapped / Isolated I/O, and Memory-mapped


I/O. Polling, Interrupts, DMA

Questions
Short answers only: no stories, please !

1. When a subroutine is executed, why is the address of the next instruction


typically saved on the stack, rather than in registers ?

2. Briefly compare Isolated (Peripheral-Mapped) I/O with Memory-Mapped


I/O.

3. Account for the relative speed difference while transferring large quanti-
ties of data, using the three I/O methods - Programmed I/O (Polling),
Interrupt-Initiated I/O, and Direct Memory Access (DMA)
4. What is microprogrammed control ? What is the advantage of using
microprogrammed control ?
5. What are the main characteristics of RISC instructions ?

Sumantra Dutta Roy, EE, IITB sumantra@ee.iitb.ac.in


CAMP Tutorial Sheet I-2

6. Explain (in not more than a few lines each), what each of the following
addressing modes are:
1. Implied Mode
2. Immediate Mode
3. Register Mode
4. Register Indirect Mode
5. Autoincrement / Autodecrement Mode
6. Direct Address Mode
7. Indirect Address Mode
8. Relative Address Mode
9. Indexed Addressing Mode
10. Base Register Addressing Mode
7. In Virtual Memory organizations, explain the advantages and disadvan-
tages of the following three ideas for the mapping table. Assume a 32-bit
address bus and a 32-bit data bus, and 512 MB, and ‘enough’ disk space
to be present.
(a) One entry per memory address
(b) One entry per {the number of chunks of the main memory that can
fit in the virtual memory }
(c) Dividing Main Memory into 4 blocks, and Virtual Memory into the
requisite number of pages

Sumantra Dutta Roy, EE, IITB sumantra@ee.iitb.ac.in


CAMP Tutorial Sheet II-1

Department of Electrical Engineering, IIT Bombay


EE309 Computer Organization, Architecture and
Microprocessors: Tutorial Sheet II
The 8085: Hardware and Interfacing

1. Consider Figure 1 (Gaonkar, Chapter 3). CS and CE denote ‘Chip Select’


and ‘Chip Enable’. OE and W E enable the output buffer of a memory
chip for a read operation, and enable a write, respectively.

(a) Specify the memory addresses of ROM1, ROM2 and R/WM1.


(b) Eliminate the second decoder and connect CS4 to CE of the R/WM1,
and identify its memory map and foldback memory. Normally, one
considers a memory range by considering all ‘don’t care’ lines as 0s.
The rest of the memory space is the foldback memory.
2. Consider Figure 2 (Gaonkar, Chapter 3).

(a) Identify the address range of the memory chip.


(b) Connect Y1 to the CE of the memory chip in place of Y0 , and identify
the address range of the memory chip.

Sumantra Dutta Roy, EE, IITB sumantra@ee.iitb.ac.in


CAMP Tutorial Sheet II-2

3. (Gaonkar, Chapter 4)
(a) Explain why a latch is used for an output port, and a tristate buffer
is used for an input port.
(b) What 8085 control signals are needed for memory-mapped I/O ?
(c) Can the µP differentiate between the cases when it is reading from
a memory-mapped input port, or reading from memory ?
4. Consider Figure (Gaonkar, Chapter 4).

(a) Identify the port addresses.


(b) If OE is connected directly to the W R signal and the output of the
decoder is connected to the latch enable (through an inverter), can
you display a byte at the output port ? Explain your answer.
5. Consider Figure (Gaonkar, Chapter 4).

(a) Justify that the arrangement shown represents peripheral-mapped


(Isolated) I/O.
(b) What is the port address if all the don’t care address lines are as-
sumed to be at logic 0 ?

Sumantra Dutta Roy, EE, IITB sumantra@ee.iitb.ac.in


CAMP Tutorial Sheet II-3

6. Consider Figure (Gaonkar, Chapter 4). Identify ports A and B as input

or output ports. What are the addresses of ports A and B ?


7. Mem(I/)Orable Question

IO/M

EN A13 .
2:4 DECODER

MSB
.
A15 .
A0
O1
A14
O0 EN
. .
DATA.
EN
BUS . OCTAL .
LATCH .
2:4 DECODER

MSB
RD
O1
WR
A13 . EN
.
. 8KB .
. ROM .
A1

(a) Identify the memory map of the ROM chip, and its foldback memory.
(b) Identify the port as an Input port or an Output Port. Is this I/O
Isolated (Peripheral-mapped), or Memory-mapped ?

Sumantra Dutta Roy, EE, IITB sumantra@ee.iitb.ac.in


CAMP Tutorial Sheet III-1

Department of Electrical Engineering, IIT Bombay


EE309 Computer Organization, Architecture and
Microprocessors: Tutorial Sheet III
8085 Programming

1. Quick Miscellany: 8085


(a) What is the maximum number of input and output devices that can
be connected to the 8085 ?
(b) Write two pieces of code to read in the contents of (i) the stack pointer
(SP), and (ii) the Program Counter (PC).
(c) Write the smallest program segment (corresponding to the minimum
number of bytes) to exchange the contents of two 16-bit registers -
the BC pair and the DE pair.
(d) i. Enumerate at least 5 one-byte commands (apart from the CMC
instruction) which cause the Carry (CY) Flag to be reset – Note
that for this question, the same basic command applid to two
differnet registers will not be treated as different commands.
ii. If one is not permitted to use the STC command or any ex-
plicit subtraction command (SUB, SUI, SBB, SBI), what are
the fastest ways to set the carry flag ? Enumerate all. ‘Fastest’
implies optimality in the total number of T-states; and out of
two programs having the same number of T-states, one corre-
sponding to a smaller number of bytes will be deemed to be the
faster one. Note that for this question, two programs with just
the data fields different will be counted as being the same.
2. Question with Strings Attached Implement the following variant of
the strcpy function: void strcpy(char * src, char * dest) Assume
all strings to be already allocated, and that the strings do not overlap.
3. More strings . . . Implement the following variant of the strncpy function:
void strncpy(char * src, char * dest, unsigned char n) Assume
all strings to be already allocated, and that the strings do not overlap.
Use src, dest as 16-bit addresses, and n as a 8-bit number. Note that in
strncpy not more than n bytes are copied. Thus, if there is no null (0)
byte among the first n bytes of src, the result will not be null-terminated.
Further, in the case where the length of src is less than n, the remainder
of dest will be padded with nulls.
4. The Highs and Lows Consider the BC register pair. Suppose you’ve
forgotten which one holds the most significant byte (a highly dangerous
thought, indeed). Write a small routine to test this out. If B contains the
most significant byte, write FFh into A, else write 00h into A. Explain
your logic.
Sumantra Dutta Roy, EE, IITB sumantra@ee.iitb.ac.in
CAMP Tutorial Sheet III-2

5. Acting Smart A small bank has a SmartCard system for all its employ-
ees. The locker room access is controlled by an 8085-based microcomputer
system. Each bank employee has a 1-byte number on his or her Smart-
Card. Only n employees have permission to use the locker room (the door
closes automatically after an employee goes in). n is specified in a byte at
memory location 2000h. A list of n codes (n ≥ 0) is stored from location
2001h onwards. Write a program segment with an infinite loop that uses
three subroutines - read card, operate door and check validity. As-
sume that the first two are given to you. read card interfaces with the
SmartCard reader on the door lock, and returns the SmartCard number
in register B. operate door uses the number in A prior to the call. If A
contains FFh, it unlocks the door, else if A contains 00h, the door stays
locked. In addition to the program segment above, write a suitable routine
for check validity,
6. (Gaonkar, Chapter 6)
(a) What is the output at port 1 when the following instructions are
MVI A, 8Fh
ADI 72h
JC display
OUT port 1
executed ?
HLT
display: XRA A
OUT port 1
HLT
(b) If the instruction ADI 72h is replaced by SUI 67h, what will be the
effect ?
MVI A, byte 1
ORA A
JM outprt
OUT 01h
7. (Gaonkar, Chapter 6) Explain the function: HLT
outprt: CMA
ADI 01h
OUT 01h
HLT
8. Looping the Loop How do you think large delays are implemented ?
Obviously, having a large number of NOP statements is not a nice method,
as the program size will become large (in terms of the number of bytes).
9. (Gaonkar, Chapter 7) The following instructions are intended to clear ten
memory locations starting from the memory address 0009h. Explain why
a large block of memory will be erased or cleared, and the program will
LXI H, 0009h
loop: MVI M, 00H
stay in an infinite loop. DCX H
JNZ loop
HLT

Sumantra Dutta Roy, EE, IITB sumantra@ee.iitb.ac.in


CAMP Tutorial Sheet III-3

LXI B, 0007h
loop: DCX B
10. (Gaonkar, Chapter 7) Loop: how many times ? MOV A, B
ORA C
JNZ loop

11. (Gaonkar, Chapter 7) What is the mathematical operation performed by


the following piece of code ?
MVI A, 07h
RLC
MOV B, A
RLC
RLC
ADD B
12. (Gaonkar, Chapter 9)
2000 LXI SP, 2100h delay: 2064 PUSH H
2003 LXI B, 0000h 2065 PUSH B
2006 PUSH B 2066 LXI B, 80FFh
2007 POP PSW loop: 2069 DCX B
2008 LXI H, 200Bh 206A MOV A, B
200B CALL 2064h 206B ORA C
200E OUT 01h 206C JNZ LOOP
2010 HLT 206F POP B
2070 RET

(a) What is the status of the flags and the contents of the accumulator
after the execution of the POP instruction located at 2007h ?
(b) Specify the stack locations and their contents after the execution of
the CALL instruction (not the CALL subroutine).
(c) What are the contents of the Stack Pointer register and the Program
Counter after the execution of the CALL instruction ?
(d) Specify the memory location where the Program Counter returns
after the subroutine.
(e) What is the final fate of the program ?
13. The CALL of the Wild Show the timing diagram with T-states corre-
sponding to the following instruction at memory location 2040h: CALL
2070h. The opcode for CALL is ‘CD’. Assume that SP initially contains
2400h. At each stage, show the following signals: ALE, A15 - A8 , AD7
- AD0 , {IO/M , S1 , S0 }, RD, W R, and the contents of the following
registers: PC, SP and the WZ (internal) register pair.
14. The RETurn of the Dragon Repeat the above excercise for the corre-
sponding unconditional return statement RET at the end of the subroutine.
15. ‘Sort of Difficult’ ... Implement the BUBBLESORT sorting algorithm
for a list of unsigned characters (bytes) in memory, along with the total
number of memory bytes to be sorted, in ascending order.

Sumantra Dutta Roy, EE, IITB sumantra@ee.iitb.ac.in


CAMP Tutorial Sheet III-4

16. IP Addresses, Ethernet Network communication is in the form of data


packets of bytes. Each machine on the network receives all packets, irre-
spective of whether the packet is meant for the machine, or not. Write an
8085 program segment with an infinite loop, to check is a packet is meant
for that machine. The IP address of a machine is a 4-byte number, such as
10.107.1.2. Suppose that the 8085-based machine stores it’s IP address
in (fixed) memory locations 2040h - 2043h. The program has an infinite
loop: it calls subroutine get packet (this places the packet in consecutive
memory locations starting from 3000h, with the first 4 bytes containing
the IP address of the machine the packet is meant for). If the IP address of
the packet matches the IP address of the machine, the system calls subrou-
tine process packet. Assume the availability of subroutines get packet
and process packet. Write code to perform the above operation.
17. Recursive Directory Listing Write a program to recursively list the files
in all subdirectories, starting from a given directory. Subroutine get info
(assume this to be given to you) returns in the HL pair, a pointer (memory
address) to a 16-byte memory block, which contains information about a
directory entry. The first byte is 77h if it is a file, and FFh if it is a
subdirectory. The first call to get info returns information about the
first entry in the current directory, and so on. If get info is called after
the last entry in the current directory has been accessed, the subroutine
returns a pointer to a block of 16 zero bytes (the pointer may be non-zero).

18. Sort of Minimally Difficult . . . First, write an O(n) subroutine min


with the following specifications: This finds out the minimum number in
a set of n numbers stored consecutively in memory (the numbers as well
as n are each 1 byte-long) - the resulting array has the same numbers,
except that the minimum is at the first location. The parameters to the
routine should be the address of the location of the first number in the
array in the DE pair, and n in the register C. This routine should not
modify the DE pair, but may modify any other register. Now, write a
subroutine selection sort, which will take parameters: the address of
the first number in the array in the HL pair, and the number of elements
(n) in register C. This should sort the n numbers, using routine min in the
process. You can assume that the stack has been appropriately initialized.

Sumantra Dutta Roy, EE, IITB sumantra@ee.iitb.ac.in

Das könnte Ihnen auch gefallen