lecture 1

28
1 Lecture 1 Instruction set of 8086 Лектор: Люличева И.А.

Upload: rene

Post on 08-Jan-2016

27 views

Category:

Documents


0 download

DESCRIPTION

Lecture 1. Instruction set of 8086. Лектор: Люличева И.А. 1. Content. 80286 MP block-diagram Universal microprocessors instruction groups Examples of programs. 80286 MP block-diagram. 3. 80286 MP. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Lecture 1

1

Lecture 1Instruction set of 8086

Лектор: Люличева И.А.

Page 2: Lecture 1

Content

80286 MP block-diagramUniversal microprocessors instruction groups

Examples of programs

Page 3: Lecture 1

80286 MP block-diagram

3

Page 4: Lecture 1

80286 MP

The second generation of x86 16-bit processors, Intel 80286, was released in 1982. The major new feature of the 80286 microprocessor was protected mode. Instruction set was changed by adding some new instructions to the existing six groups.

Page 5: Lecture 1

5

Universal microprocessors instruction groups

Instruction set of MP x86 consist of 6 groups:

1. Data transfer instructions. 2. Arithmetical instructions. 3. Logical operations and shift

instructions. 4. Flow control instructions. 5. Chains (arrays) instructions. 6. Microprocessor control instructions.

Page 6: Lecture 1

Basics of instruction set of MP or MC

3 types of instruction format

http://www.c-jump.com/

6

Page 7: Lecture 1

7

Flow control instructions Segmentation leads to two types of the flow

control: Inside the segment - only IP changes.

Type - NEAR, or short addressing. Outside the segment. Type - FAR - both

IP and CS change (segment: bias) ES:DI Segment registers areCS, DS, ES, SS

Page 8: Lecture 1

8

Flow control instructions

May be divided on 5 subgroups: Unconditional jumps, Conditional branches, Subroutines call and return, cycles Interrupts instructionsLet us look at each groups .

Page 9: Lecture 1

9

Flow control instructions Unconditional JMPs may be short or long

and direct/indirect.

JMP dispL 16- short jump JMP mem/reg - near indirect jump JMP addr32 - far jump JMP mem- far indirect jump

Page 10: Lecture 1

10

Flow control instructions

19 conditional branches All of them are short and may be executed ander

some condition: Mnemonics: 1) for unsigned data JA/JNBE - if more (>); JAE/JNB/JNC - >= JB/JNAE/JC - <; JBE/JNA - <=. 2) For signed data: JG/JNLE - >; JGE/JNL - >=; JL/JNGE - <; JLE/JNG - <=; JNS - >0; JS - <0.

Page 11: Lecture 1

11

Flow control instructions 3) Conditional jumps: JE/JZ — jump if

equal (if zero); JNE/JNZ — if not zero ; JNO/JNC - jump if not carry; JO/JC- jump on carry. Additional instr: JCXZ - jump ix CX=0; JNP/JPO - jump if odd (not parity); JP/JPE - if even (if parity) .

Page 12: Lecture 1

12

Flow control instructions 3 instr for cycles - use CX as a counter. Only

short jumps on -128 - +127 bytes from current point.

LOOP make CX-- and continue the cycle until CX=0

For example @m1: … Loop @m1

Page 13: Lecture 1

13

Flow control instructions Short delay subroutin MOV CX, 1000 M1: DEC CX JNZ M1You my write the same in a short way,

using loop instruction: MOV CX, 1000 M1: LOOP M1

Page 14: Lecture 1

14

Flow control instructions For work with subroutines Call subroutine: Call @Pr1 …. @Pr1: Push ax Add ax, bx Mov ES:[di], ax Pop ax Ret

Page 15: Lecture 1

15

6. MP control instructions

Control MP functioning. For 8086 only work with flags and

synhroniz.(NOP, wait etc). In 80286, 80386 ++ - additional 10 -

20 mnemonics.

Page 16: Lecture 1

16

Work with chains Chain is a consequence of chained

bytes or words, которые находятся в смежных ячейках памяти.

MP 8086 has 5 chains instructions They may work with the special

prefixes

Page 17: Lecture 1

17

Work with chains Simple pref is REP, wich leads to the

repetition of action on the next chain element. Повторение рассчитано на максимальную длину цепочек 64К и выполняется значительно быстрее цикла LOOP.

Цепочечные команды могут иметь только один операнд-источник, или операнд-получатель или оба операнда одновременно. В качестве адреса операнда-источника (SRC) всегда используется регистровая пара DS:SI.

Операнд-получатель – всегда пара ES:DI.

Page 18: Lecture 1

18

Work with chains Instruction MOVS sends one byte

or word from the chain, addressed by DS:SI, into the chain, addressed by ES:DI.

Format: MOWSB or MOVSW Works with the REP prefix

Page 19: Lecture 1

19

Work with chains Compare bytes or words in a chain

with AL or AX CMPS Formate: CMPSB or CMPSW Works with REPE or REPNE prefix

Page 20: Lecture 1

20

Work with chains Instructions STOSB/W save AL or AX

into a chain, addressed by ES:DI. Format STOSB, STOSW Below are 2 examples of long description

of these instr.

Page 21: Lecture 1

Instruction STOSB

Store byte in AL into ES:[DI]. Update DI.Algorithm: ES:[DI] = ALif DF = 0 then DI = DI + 1

else DI = DI - 1

21

Page 22: Lecture 1

Instruction STOSW

Store word in AX into ES:[DI]. Update DI.Algorithm: ES:[DI] = AXif DF = 0 then DI = DI + 2

else DI = DI - 2

22

Page 23: Lecture 1

2323

Work with chains

Example of using STOSB/W for clear screen. Block diagram

Page 24: Lecture 1

24

Work with chains Example of program.

MOV AX, 0B800H { Do not repeat MOV ES, AX { futher! } XOR DI,DI MOV CX, 80*25 XOR AX,AX REP STOSW

Page 25: Lecture 1

2525

Examples of programs Block-diagr of using STOSB/W for filling 10th

line of Pc screen by number 3.

Page 26: Lecture 1

26

Examples of programs Example of using STOSB/W for filling

10th line of Pc screen by number 3. MOV DI, 160*10 (1 -2 bytes!) MOV CX, 80 MOV AX, 1E33Н (33Н – ASCII code for 3) REP STOSW

Page 27: Lecture 1

2727

Examples of programs

Block-diagr for filling the colomn.

Page 28: Lecture 1

28

Self-control questions Groups of instr 8086 Far and long jumps. Поясните особенности команд работы с

цепочками и сегментных регистров. Приведите примеры использования команд

работы с цепочками. Приведите пример программы

циклического опроса 20 портов и укажите использованные виды адресации