+ All Categories
Home > Documents > lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer...

lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer...

Date post: 19-Mar-2018
Category:
Upload: buidang
View: 220 times
Download: 0 times
Share this document with a friend
32
Computer Operation 1/2/2011 1
Transcript
Page 1: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Computer Operation

1/2/2011 1

Page 2: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Sequential Machine

• A digital computer is a sequential machine.

• The CPU (microprocessor) executes instructions in a

1/2/2011 2

• The CPU (microprocessor) executes instructions in a

sequence as specified by the program.

• In general terms the instructions are executed in the

sequence they are written.

• However a certain class of instruction can vary the

instruction execution sequence.

Page 3: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Function of Memory System

• The function of the memory system of a digital computer is :

1/2/2011 3

digital computer is :

Provide a storage facility for the program ( the

instructions ) the microprocessor is required to

execute.

Provide a storage facility for the data that

is to be manipulated by those instructions.

Page 4: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

The Instruction Cycle• There are two stages to the complete execution of an

instruction :

Stage 1 : CPU fetches the instruction from memory

1/2/2011 4

Stage 2 : CPU executes the instruction

Page 5: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Instruction Fetch

• Processor places address

of where the instruction is

stored onto address bus

• Processor asserts the read

1/2/2011 5

• Processor asserts the read

control line

• The memory device places

the data at the addressed

location onto the data bus

• The processor reads the

instruction byte.

Page 6: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Instruction Format• Instructions are stored in program

memory in binary coded form.

• Since an instruction must represent a complete and unambiguous statement of the operation required of the

1/2/2011 6

of the operation required of the processor then 8-bits (the number of bits of a single memory location) is often insufficient to specify the complete instruction.

• Depending on the particular instruction, 8085A instructions occupy one, two or three successive memory locations.

Page 7: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

The Opcode

• The first byte of an instruction is called the

Opcode

1/2/2011 7

• It describes :The operation to be carried out e.g move data,

arithmetic operation, logical operation etc

Where the source data is located in the computer

How many bytes constitute the complete instruction

The destination for the result of the operation

Page 8: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Example of Opcode• Consider the instruction: STA addr

• Opcode in assembly language form STA

• Opcode in machine language form (i.e. the bits that

are actually stored in memory) 00110010 (32H)

1/2/2011 8

• The opcode specifies :

The destination for the data is external memory

Data is to be moved

The source of the data is the CPU register A

The complete instruction is three bytes long

Bytes 2 & 3 of the instruction specify the address of the memory location

where the data is to be written.

Page 9: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Where the Opcode is Stored in the CPU

• Once read from memory, the opcode of the instruction is stored

in the instruction register (an 8-bit register) of the CPU.

1/2/2011 9

Page 10: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Instruction Decoder and Control Logic

• The contents of the instruction register is read by the instruction decoder.

• The instruction decoder configures the control logic so that the particular sequence of CPU operations are carried out to complete execution of the instruction.

1/2/2011 10

complete execution of the instruction.

• This will include fetching the remaining bytes of an instruction, if the instruction is a multibyte instruction.

• The second ( and third ) bytes of a multibyte instruction are accessed by the CPU in exactly the same way as the opcode is fetched from memory. The second ( and third ) bytes of an instruction are stored in temporary registers in the CPU.

Page 11: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

The Program Counter• The program counter is a 16-bit CPU register.

• The program counter always contains the address of the memory location from where the CPU is to fetch the next instruction byte.

1/2/2011 11

• The program counter is automatically incremented every time the CPU fetches an instruction byte. Instructions are thus executed in the sequence they are loaded into program memory.

• The contents of the program counter can be overwritten by execution of certain instructions e.g. jmp, call, ret etc.

• The program counter is initialised to 0000H after processor reset or on power-up.

Page 12: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Example of Instruction Execution

• The following are the sequence of operations the processor is required to perform to execute the instruction STA addr

• Place program counter onto address bus ; opcode address

• Assert control signalRD

1/2/2011 12

• Assert control signal

• Read opcode and load into instruction register ; PC incremented

• Decode the opcode

• Place program counter onto address bus ; address of byte 2

• Assert control signal

• Read byte 2 and save in temp register W ; PC incremented

• Place program counter onto address bus ; address of byte 3

• Assert control signal

• Read byte 3 and save in temp register X ; PC incremented

RD

RD

RD

Page 13: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Example of Instruction Execution

• The whole of the instruction has been fetched at this stage. The 8-bit temporary registers W & X contain the 16-bit address of the memory location at which the contents of CPU register A is to be

1/2/2011 13

memory location at which the contents of CPU register A is to be stored.

• The execution phase of the instruction can now take place.

• Place the contents of W & X onto the address bus ; specify memory address

• Place the contents of register A onto data bus ; data to be written

• Assert control signal ; write data to memoryWR

Page 14: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

8085 Internal Architecture

1/2/2011 14

Page 15: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

• The register file :

1/2/2011 15

Page 16: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

The Register File• 6X 8-bit registers with addresses B, C, D, E, H & L

• Can be concatenated to form 3X 16-bit registers with addresses BC, DE & HL.

• Note : 16-bit register HL used as a memory pointer with many 8085A instructions.

1/2/2011 16

– (e.g MOV A, M which copies the contents of the memory location

whose address is specified by the contents of the HL register pair to

the CPU register A)

– (Note the assembly language instruction format

• MOV <destination> <source>)

• 16-bit register SP. It contains the address of the memory location of the top of the stack area of memory. It is automatically controlled by the processor but can be initialised

by software.

Page 17: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

How the Stack Works

• The stack is a reserved area of memory. It operates as a last-in first-out bank of registers.

• The memory locations, which constitute the stack, are used to store binary information temporarily during program execution.

• The stack can be located anywhere in read/write memory, but is

1/2/2011 17

• The stack can be located anywhere in read/write memory, but is usually defined such that it neither interferes with the program memory space or the data memory space.

• The start address of the stack is specified at the initialisation stage of the program by loading the 16-bit CPU register, called the stack pointer, with the desired address of the start of the stack.

– e.g LXI SP, data 16

Page 18: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

How the Stack Works

• Data from CPU register pairs are stored in the stack area of memory when the processor executes a push rp instruction.

• The contents of the program counter is automatically stored in the stack area of memory whenever the processor executes a call or restart (rst n) instruction.

1/2/2011 18

call or restart (rst n) instruction.

• Data stored in the stack area of memory are returned to processor register pairs when the processor executes a pop rpinstruction.

• Data is automatically transferred from the stack area of memory to the program counter whenever the processor executes a return (ret) instruction.

Page 19: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Writing to the Stack

• To execute the instruction push HL

assuming initial sp contents is

2099 H.

• The stack pointer is decremented

by 1 (sp=2098) and the contents of

H are written to this location.

1/2/2011 19

• The stack pointer is decremented

by 1 (sp=2097) and the contents of

L are written to this location.

• Note : When data is written to the

stack the stack pointer is first

decremented and then the data is

written

Page 20: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Reading from the Stack

• To execute the instruction pop BC

assuming initial sp contents is

2097 H.

• The contents of the memory

location at the address specified by

the contents of sp is moved to

1/2/2011 20

the contents of sp is moved to

register C and sp is incremented.

• The contents of the memory

location at the address specified by

the contents of sp is moved to

register B and sp is incremented.

• Note : When data is read from the

stack the data is read first and then

the stack pointer incremented.

Page 21: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Other 8085A CPU Features

• The ALU unit

1/2/2011 21

Page 22: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

The ALU Subsystem

• More detailed schematic

1/2/2011 22

Page 23: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

The ALU Subsystem• The ALU itself is a group of combinatorial logic circuits that can

perform 8-bit arithmetic and logical operations. Included are :-add, sub, and, or, xor

• The accumulator ( reg A ) is an 8-bit general purpose register that holds one of the source operands of an ALU operation. The result of the operation is also returned to the accumulator.

1/2/2011 23

result of the operation is also returned to the accumulator.

• The temporary accumulator is an 8-bit register that holds the second operand used in a ALU operation. It is inaccessible to the user.

• The decimal adjust unit allows the ALU to perform BCD arithmetic. (rarely used as it is usual to use binary, as opposed to BCD, arithmetic)

Page 24: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

The Flag Register

• The flag register is a collection of eight, single bit registers. It reflects outcomes of arithmetic or logical operations.

1/2/2011 24

• The Sign Flag (S) reflects the contents of bit-7 of the accumulator

• The Zero Flag (Z) is set to ‘1’ if the accumulator contains all zero’s

• The Auxiliary Carry (AC) is a ‘1’ if the arithmetic operation caused a

carry out from the bit-3 to the bit-4 position. (The auxiliary carry flag is

used in BCD arithmetic)

• The Parity Flag (P) is a ‘1’ if the accumulator has an even number of ‘1’s

• The Carry Flag (CY) is set if the arithmetic operation caused a carry

overflow (from addition) or a borrow (from subtraction).

Page 25: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Example of an Arithmetic Operation

• ADD B ; A contains 88 (H) B contains 99 (H)

register A 1 0 0 0 1 0 0 0 1 3 6 decimal

register B 1 0 0 1 1 0 0 1 1 5 3 decimal

_____________ _____

register A 1 0 0 1 0 0 0 0 1 2 8 9 decimal

1/2/2011 25

register A 1 0 0 1 0 0 0 0 1 2 8 9 decimal

• S = 0 Bit D7 = 0 after addition

• Z = 0 The accumulator contains other than zero after addition

• AC = 1 There is a carry out of bit D3 to bit D4 during addition

• P = 1 The accumulator contains an even number of ‘1’s

after addition

• CY = 1 There is an overflow as a result of the addition

Page 26: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

More on the Control Logic• The control logic subsystem of a microprocessor is a

configurable sequential state machine.

• It is configured by the instruction decoding circuitry to enable execution of a particular instruction.

1/2/2011 26

• It has associated with it a number of inputs and outputs, both from other subsystems of the CPU and from external devices.

• It operates with respect to a stable clock reference signal provided by a crystal source. Typical clock frequencies for an 8085A microprocessor are in the order of 5-MHz.

• The internal clock for the control logic is half the frequency of the external crystal source (i.e internally the crystal source clock is divided by 2)

Page 27: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Control Logic - External Inputs and Outputs

1/2/2011 27

Page 28: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Function of Control Logic Inputs and Outputs

)(oRD A logic ‘0’ specifies the processor will readthe data on the data bus.

)(oWR A logic ‘0’specifies that the processor has placed data (write) onto the data bus foran external device to read.

1/2/2011 28

A 3-bit status code that specifies the operation the processor is performing. (e.g 110 specifies the processor is fetching an opcode from program memory).

)(/10 oMIOSS

)(ooutreset A logic ‘1’ on the reset in input to the processor causes the program counter to be reset to 0000H. To indicate the processor has been reset a logic `1’, synchronised to the processor clock, is placed on this output.

Page 29: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Function of Control Logic Inputs and Outputs

)(ooutCLK Is a buffered version of the internal master clock of the 8085A. It is half the crystal frequency.

)()( oHLDAiHOLD An external device can request use of the system busses by driving the HOLD input to logic ‘1’. The 8085A acknowledges the request by asserting the

1/2/2011 29

8085A acknowledges the request by asserting the HLDA output to logic ‘1’. It only does after it has

relinquished control of the bus structure.

)(oALE When this signal is logic ‘1’ the processor specifies that it has valid address information on the CPU pins 70−

AD

)(iRDY When this signal is logic ‘0’ the processor suspends execution of an instruction. It permits slow peripheral devices more time to access or load data.

Page 30: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

8085A Bus Interfaces

• The 8085A microprocessor uses only 16 connections

to interface the 8-bit data bus and 16-bit address bus.

• Address bus lines are time multiplexed with

data bus lines70−

A

70−

D

1/2/2011 30

70−

D

Page 31: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

Address Latches• Peripheral devices ( memory and IO ) require stable address

data throughout a read or write operation.

• The processor only provides A0 - A7 during the period ALE is in the logic ‘1’ state after which the multiplexed lines AD0 - AD7 assume the role of the data bus. ( D0 - D7 )

1/2/2011 31

• To provide external devices with stable address data throughout a read or write operation it is necessary to latch the low byte of the address using the ALE control signal.

• By this mechanism it is possible for the 8085A computer system to have a 16-bit address bus and an 8-bit data bus whilst only using 16 processor connections ( AD0 - AD7 and A8 - A15 )

Page 32: lecture2 comp operation.ppt - portal.unimap.edu.myportal.unimap.edu.my/portal/page/portal30/Lecturer Notes...Where the Opcode is Stored in the CPU • Once read from memory, the opcode

De-multiplexing AD0 - AD7

1/2/2011 32

Note : See through latches ( eg 74LS573 ) are the preferredtype of latch. When clk (ALE) is logic ‘1’ the latch outputs follow the inputs and on the negative edge of clk the data is latched.


Recommended