250 likes | 398 Views
Lecture 2. Programming of 8086. Лектор: Люличева И.А. 1. Content. Addressing modes of х86 Examples of programs Examples of using ports. Universal microprocessors instruction groups. Instruction set of MP 8086 consist of 6 groups: 1. Data transfer instructions .
E N D
Lecture 2 Programming of 8086 Лектор: Люличева И.А. 1
Content Addressing modes of х86 Examples of programs Examples of using ports
Universal microprocessors instruction groups Instruction set of MP 8086 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. 3
Addressing modes The x86 processors support • the register addressing mode , • the immediate addressing mode, • the direct addressing mode, • implicit addressing mode, • the indirect addressing mode, • stack addressing mode, • the base plus index addressing modes, • and the base relative plus index addressing mode. 4
Addressing modes Register operands are the easiest to understand. Consider the following forms of the mov instruction: mov ax, bx or mov ax, cx Constants are also pretty easy to deal with. Consider the following instructions: mov ax, 1e41h or add di, 160
Addressing modes Direct addressing mode to Memory we rear will use: Mov ax, [100] But to ports it may be useful: In al, 40h or In ax, 60h implicit addressing mode: STOWS, MOWSW, DAA, WIAT, NOP, LOOP Stack addressing mode uses SS:SP pair Instructions: Push, Pop, Call, Ret 6
Addressing modes the indirect addressing mode may be of 3 types 1. index – using DI or SI Mov es:[di], ax 2. base – using BX or BP Mov ax, ds:[bx] 3. indirect to ports Mov dx, 3E8h In ax, dx 7
Addressing modes the base plus index addressing modes we may use for two dimensional arrays: Mov ax, [bx+di] or add [bp+si], 2000h Index or base relative addressing mode (with the bias) we used in laboratory work N1: Mov ES:[DI+2000], AX 8
Addressing modes Indirect addressing modes for 16-bit x86 processors can be summarized by this formula:
Work with chains • Example of clear screen program MOV AX, 0B800H{ Do not repeat MOV ES, AX{ futher! } XOR DI,DI MOV CX, 80*25 XOR AX,AX REP STOSW 10
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 11
Examples of programs Example of filling the colomn by increasing code. MOV AX, 0B800H MOV ES, AX XOR DI,DI MOV CX, 25 MOV AX, 2F41H (41H – code of А) @L1:MOV ES:[DI], AX INC AX ADD DI, 160 LOOP @L1 13 13
Microprocessor based Systems contains: • CPU (central processing unit) • Microprocessor core • Cash memory • logic circuitry for communicating with the system bus: data/address bus driver, bus controller System memory stores both program code and data ROM, BIOS (read-only memory), RAM (random access memory) Timing unit • generates clock signals and is responsible for the proper operation of all system hardware • crystal oscillator and timing circuitry Interrupt circuitry • mechanism for the processor to respond to special external events • I/O, peripherals • Dicks, monitor, keyboard, mouse, printer, …
Examples of programs • Input array of data from port 40H and output it to the colomn at the screen. XOR DI,DI MOV CX, 25 @L1:IN AX, 40H {40H – address of port} MOV ES:[DI], AX ADD DI, 80 LOOP @L1 21
Examples of programs Block-diagr for 100 times input arrays from ports with the delay. • 1. Counter= (100) • 2. Execute the subroutine of input array from port. • 4. call delay • 6. counter-- • 7. Counter= 0? – of NOT go to p.2 else - END. 22
Self-control questions • Groups of instr 8086 • Far and long jumps. • Addressing modes in the example 1 • Addressing modes in the programm of input data from the ports 25