280 likes | 421 Views
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.
E N D
Lecture 1 Instruction set of 8086 Лектор: Люличева И.А. 1
Content 80286 MP block-diagram Universal microprocessors instruction groups Examples of programs
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.
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. 5
Basics of instruction set of MP or MC • 3 types of instruction format • http://www.c-jump.com/ 6
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 are CS, DS, ES, SS 7
Flow control instructions May be divided on 5 subgroups: • Unconditional jumps, • Conditional branches, • Subroutines call and return, • cycles • Interrupts instructions Let us look at each groups . 8
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 9
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. 10
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) . 11
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 12
Flow control instructions • Short delay subroutin • MOV CX, 1000 • M1: DEC CX • JNZ M1 You my write the same in a short way, using loop instruction: • MOV CX, 1000 • M1: LOOP M1 13
Flow control instructions • For work with subroutines • Call subroutine: Call @Pr1 • …. • @Pr1: • Push ax • Add ax, bx • Mov ES:[di], ax • Popax • Ret 14
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. 15
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 16
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. 17
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 18
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 19
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. 20
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
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
Work with chains Example of using STOSB/W for clear screen. Block diagram 23 23
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 24
Examples of programs Block-diagr of using STOSB/W for filling 10th line of Pc screen by number 3. 25 25
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 26
Examples of programs Block-diagr for filling the colomn. 27 27
Self-control questions • Groups of instr 8086 • Far and long jumps. • Поясните особенности команд работы с цепочками и сегментных регистров. • Приведите примеры использования команд работы с цепочками. • Приведите пример программы циклического опроса 20 портов и укажите использованные виды адресации 28