Chapter 5B
Chapter 5B
Interfacing Communications
-STACK, DIRECT MEMORY
ACCESS, BUS
Direct Memory Access
• Method of transferring data from the
computer's RAM to another part of the computer
without processing it using the CPU
• While most data that is input or output from your
computer is processed by the CPU, some data does
not require processing, or can be processed by
another device.
• DMA can save processing time and is a more
efficient way to move data from the computer's
memory to other devices.
• Required conditions for DMA
– The I/O interface and memory must be connected
– The I/O module must be capable of reading and
writing to memory
– Conflicts between the CPU and the I/O module
must be avoided
– Interrupt required for completion
Examples
• A sound card may need to access data stored
in the computer's RAM, but since it can
process the data itself, it may use DMA to
bypass the CPU.
• Video cards that support DMA can also access
the system memory and process graphics
without needing the CPU.
DMA Instructions
• Application program requests I/O service from
operating system
– privileged programmed I/O instructions
• 4 kinds of signals
1. Data
2. Addressing
3. Control signals
4. Power (sometimes)
Bus Characteristics
• Number of separate conductors
• Data width in bits carried simultaneously
• Addressing capacity
• Lines on the bus are for a single type of signal or shared
• Throughput - data transfer rate in bits per second
• Distance between two endpoints
• Number and type of attachments supported
• Type of control required
• Features and capabilities
Parallel vs. serial buses
• Parallel
– High throughput because all bits of a word are transmitted simultaneously
– Expensive and require a lot of space
– Generally used for short distances such as CPU buses and on computer motherboards
• Serial
– 1 bit transmitted at a timed
– Single data line pair and a few control lines
– For many applications, throughput is higher than for parallel because of the lack of
electrical interference
Direction of transmission
• Simplex – unidirectional
• Half duplex – bidirectional,
one direction at a time
• Full duplex – bidirectional
simultaneously
Method of interconnection
• Point-to-point – single source • Multipoint bus – also
to single destination broadcast bus or multidrop bus
– Cables – point-to-point – Connect multiple points to
buses that connect to an one another
external device
Point-to-point vs. Multipoint
Plug-in Broadcast
device bus
Example:
Ethernet
Shared among
multiple devices
Stack
• Used by the CPU to store information from
registers temporarily
• This is because there is limited number of
register inside the microprocessor
• The two main registers to access the stack are
SS and SP registers
Types Of Stack
• There are two types of stacks:
Hardware stack – a number of registers are set aside
within the processor to serve as the stack location.
ADVANTAGE is rapid access time.
DISADVANTAGE is limited numbers of registers
Software stack – an area inside the RAM for
temporary storage. ADVANTAGES are almost
unlimited size and can reside anywhere inside the
memory. DISADVANTAGE is slow access time
Stack Functions/Usages
Finally, SP is : 122F
Popping Off Stack
Given the following stack and SP = 18FA,
show the contents of the stack and registers
after executing the following instructions.
18FA
18FB 23
SP 18FC 14
18FD 6B S
18FE 2C
18FF 91 S
1900 F6
(usually the stack is build following
1901
the25
little endian method)
18FA
POP CX 18FB 23
18FC 14
POP DX 18FD 6B
POP BX 18FE 2C
18FF 91
1900 F6
SP : 1900 1901 25
CX: 1423
DX: 2C6B
BX: F691
Little Or Big Endian
• Little Endian method :
– the high byte goes to the high address
– the low byte goes to the low address
• Big endian method:
– the low byte goes to the high address
– the high byte goes to the low address
• All Intel microprocessor and many
minicomputers use LITTLE ENDIAN method
• Motorola (used in MAC) and some
mainframes use BIG ENDIAN method
Exercise
• Based from the instructions given below, draw an
appropriate stack diagram, starting from address
2000
MOV AX, 1234h
MOV BX, 9ABCh
PUSH BX
PUSH AX
• State the content of the stack pointer after the
execution of the above instructions
• Arrange the words in the stack using
– Big Endian
– Little Endian
Past semester Question
• Given the content of registers and the byte that follows the
PUSH instruction at the time interrupt occurs:
PC : 2602h
AX : F6h
BX : 82h
CX : 3624h
DX : FB12h
Flag Register : 15h
• BYTE
X X 1 0 1 1 1 1
PC DX CX Flag Register BX AX
a) Draw the content of the stack (with related
addresses) after the interrupt occurred
(following the sequence of PC, AX, CX, DX,
and BX). Assume that the last item stored in
the stack (SP) is at the location FF00.
b) Why stack is needed when an interrupt
occurs?
References
• http://www.techterms.com/definition/dma
• http://www.embedded-systems-portal.com/
CTB/Direct_Memory_Access,1006.html