Introduction to Microprocessors Chapter 3. Programming Model (8086) Shows the various internal...

27
Introduction to Microprocessors Chapter 3

description

General Purpose Registers

Transcript of Introduction to Microprocessors Chapter 3. Programming Model (8086) Shows the various internal...

Page 1: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Introduction to Microprocessors

Chapter 3

Page 2: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Programming Model (8086)Shows the various internal registers that are

accessible to the programmer

Page 3: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

General Purpose Registers

Page 4: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Data Registers

Page 5: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Pointer and Index Registers

Page 6: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Example

MOV AH,[SI]Assume SI=1000After executing programAH = 26H

Page 7: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Status and Control Flags

Page 8: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Flags Carry Flag (CF) - this flag is set to 1 when there is an unsigned overflow. For example when you add

bytes 255 + 1 (result is not in range 0...255). When there is no overflow this flag is set to 0.

Parity Flag (PF) - this flag is set to 1 when there is even number of one bits in result, and to 0 when there is odd number of one bits. 

Auxiliary Flag (AF) - set to 1 when there is an unsigned overflow for low nibble (4 bits).

Zero Flag (ZF) - set to 1 when result is zero. For non-zero result this flag is set to 0.

Sign Flag (SF) - set to 1 when result is negative. When result is positive it is set to 0. (This flag takes the value of the most significant bit.)

Trap Flag (TF) - Used for on-chip debugging. Processor operate in a single stepping mode.

Interrupt enable Flag (IF) - when this flag is set to 1 CPU reacts to interrupts from external devices.

Direction Flag (DF) - this flag is used by some instructions to process data chains, when this flag is set to 0 - the processing is done forward, when this flag is set to 1 the processing is done backward.

Overflow Flag (OF) - set to 1 when there is a signed overflow. For example, when you add bytes 100 + 50 (result is not in range -128...127).

Page 9: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

ExampleIf AL=7F and instruction ADD AL,1 is given,

the flags are (7F+1=80H)CF=0PF=0AF=1ZF=0SF=1OF=1

Page 10: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Memory Address Space and Organization

Memory space of 8086 consists of 1,048,576 bytes or 524,288 16-bits words

Page 11: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Even addressed and odd-addressed banks

IF 16-bit word begins at an odd address, 8086 will require two memory read or write cycles

Page 12: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Origin and Definition of a Segment

A segment is an area of memory that includes up to 64Kbytes and begins on an address divisible by 16 (such an address ends with an hex digit 0h or 0000b)

In the 8086/88, 64 K is assigned to each categoryCode segment Data segment Stack Segment Extra Segment

Page 13: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Advantages and disadvantages of Segmented Memory

One program can work on several different sets of data. This is done by reloading register DS to a new value.

Programs that reference logical addresses can be loaded and run anywhere in the memory: relocatable

Segmented memory introduces extra complexity in both hardware in that memory addresses require two registers.

They also require complexity in software in that programs are limited to the segment size

Programs greater than 64 KB can be run on 8086 but the software needed is more complex as it must switch to a new segment.

Protection among segments is provided.

Page 14: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Segment Registers

Page 15: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Logical and Physical Addresses

Page 16: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Example

Page 17: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

16 bit Segment Register Assignments

Page 18: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Addressing Modes When the 8086 executes an instruction, it performs the specified function on data These data, called operands,

May be a part of the instruction May reside in one of the internal registers of the microprocessor May be stored at an address in memory

Register Addressing Mode MOV AX, BX MOV AL,BH

Immediate Addressing Mode MOV AL,15h MOV AX,2550h MOV CX,625

Page 19: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Direct Addressing Mode

A memory location is to be referencedEx: MOV CL,[20H] ; 8 bit transferNote the brackets around 20hEx2: MOV CX,[20H] ; 16 bit transfer

Page 20: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Example for Register Indirect Addressing

Page 21: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

MOV instructionsMOV destination, source8 bit moves

MOV CL,55hMOV DL,CLMOV BH,CL

16 bit movesMOV CX,468FhMOV AX,CXMOV BP,DI

Page 22: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

MOV Instruction

Page 23: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

MOV instruction

Page 24: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

ADD Instruction

Page 25: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Data Segment

Page 26: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Data Segment

Page 27: Introduction to Microprocessors Chapter 3. Programming Model (8086)  Shows the various internal registers that are accessible to the programmer.

Data Segment