Microprocessor - 8086

Views:
 
Category: Entertainment
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

Microprocessor - 8086:

Microprocessor - 8086 N. Mathivanan

8086 – Internal Architecture:

8086 – Internal Architecture EU - Execution Unit General Purpose Registers Pointer Registers Index Registers ALU Flags BIU - Bus Interface Unit Segment Registers CS, DS, ES, SS, IP Queue Memory Addressing Segment Base Offset

Flags:

Flags Flags SF, ZF, AF, PF, and CF as in 8085 Trap Flag, Interrupt Flag, Direction Flag, Overflow Flag

Addressing Modes:

Addressing Modes Immediate Addressing MOV AL, 2AH; MOV CX, AAAAH Register Addressing MOV AL, BL; MOV CX, AX Segment Register can not be copied into another segment register Code Segment cannot be a destination Memory Addressing 24 ways Direct Addressing

8086 Instructions:

8086 Instructions Data Transfer Instructions MOV destination, source; PUSH source; POP destination XCHG destination, source; XLAT LEA register, source; LDS register, memory; LES register, memory IN AL, dd; OUT DX, AX Arithmetic Instructions ADD dest, source; ADC dest, source; INC dest; AAA ; DAA; SUB dest, source; SBB dest, source; DCE dec; AAS ; DAS ; NEG dest; MUL source; IMUL source; AAM DIV source; IDIV source; AAD ;

Example Programmes:

Example Programmes Programme to covert temp. value from Fahrenheit to Celsius SUB AL, 32D ; AL contains F value, (F-32D) is computed MOV CL, 05H ; MUL CL ; (F-32D) x 5 is computed and stored in AX MOV CL, 09H ; DIV CL ; (F-32) x 5 / 9 is computed and stored in AL ---------------------------------------------------------------------------------------------------------

8086 Instructions Continued:

8086 Instructions Continued Bit-manipulation instructions NOT dest; AND dest, sour; OR dest, sour; XOR dest, sour; TEST dest, sour SHL dest, count; SAL dest, count; SHR dest, count; SAR dest, count; ROL dest, count; RCL dest, count; ROR dest, count; RCR dest, count; String Instructions MOVS / MOVSB / MOVSW CMPS / CMPS / CMPSW LODS / LODSB / LODSW STOS / STOSB / STOSW SCAS / SCASB / SCASW

Example Programmes:

Example Programmes Programme to count number of logic ones MOV CL, 08H ; number of bits to be counted MOV BL, 00H ; BL to count number of ones L1: ROL AL, 01 ; AL holds the byte, the MSB is rotated to CF JNC L2 ; if no carry, go to test next bit INC BL ; if carry, increment the counter L2: DEC CL ; JNZ L1 ; if not all the bits tested, test the next bit --------------------------------------------------------------------------------------------------------- Programme to move block of data CLD ; clear direction flag MOV AX, 2000H MOV DS, AX ; initialize DS MOV AX, 3000H MOV ES, AX ; initialize ES MOV SI, 0004H ; offset of the source location in data segment MOV DI, 0014H ; offset of the destination location in extra segment MOV CX, 0006H ; the length of the string REP MOVSB ; copy the string bytes from source to destination ---------------------------------------------------------------------------------------------------------

8086 Instructions Continued:

8086 Instructions Continued Branch Control Instructions JMP addr; Conditional Jump instructions CALL proc RET Iteration Control Instructions LOOP label; LOOPE / LOOPZ label; LOOPNE / LOOPNZ label; JCXZ label Interrupt Instructions INT type; INTO ; IRET Processor Control Instructions STC; CLC; CMC; STD; CLD; STI; CLI

Subroutine Program:

Subroutine Program ---- MOV AL, --H ; first BCD number to AL CALL BCDTOBIN ; call the subroutine to convert BCD to binary MOV CL, AL ; save in CL MOV AL, --H ; second BCD number to AL CALL BCDTOBIN ; call the subroutine to convert BCD to binary MUL CL ; compute the product --- ; Subroutine programme BCDTOBIN: PUSHF ; save flags PUSH BX ; save BX PUSH CX ; save CX MOV BL, AL ; copy the BCD number to BL AND BL, 0FH ; separate the BCD number to two nibbles AND AL, 0F0H ; MOV CL, 04H ; ROR AL, CL ; MOV CH, 0AH ; convert the MSB digit of BCD number to binary MUL CH ADD AL, BL ; add the LSB digit and hold binary value in AL POP CX ; restore CX POP BX ; restore BX POPF ; restore flags RET ; return to main programme -----------------------------------------------------------------------------------------------------------

Assembler:

Assembler MASM, TASM, ASM-86 MASM Tools: Editor , Assembler , Linker , Debugger Assembler Directives SEGMENT , ENDS DB, DW, DD EQU, ASSUME, LABEL, END PROC, ENDP EXTERN, PUBLIC, GLOBAL OFFSET PTR ORG

Programming Examples:

Programming Examples Compute product of two unsigned binary numbers MYDATA SEGMENT VALUE1 DB 1AH ; first value VALUE2 DB 2BH ; second value PRODUCT DW 1 DUP(0) ; result of product MYDATA ENDS MYCODE SEGMENT ASSUME CS:MYCODE, DS:MYDATA START: MOV AX, MYDATA ; to initialize DS MOV DS, AX MOV AL, VALUE1 ; first value in AL MUL VALUE2 ; multiply by second value MOV PRODUCT, AX ; Store product INT 03H ; Breakpoint MYCODE ENDS END START

Slide 13:

Programme to find largest value in an array of words MYDATA SEGMENT LARGE DW 1 DUP(0) ; Storage for the largest value LENGTH DW 0005H ; Number of values, 5 VALUES DW 012AH, 231BH, 0FABCH, 0021H, 0A286H ; The five values MYDATA ENDS MYCODE SEGMENT ASSUME CS:MYCODE, DS:MYDATA START: MOV AX, DATA ; Initialize DS MOV DS, AX MOV CX, LENGTH ; Number of values in CX MOV SI, OFFSET VALUES ; SI pointed to the first value MOV AX, WORD PTR [SI] ; First value to AX L1: INC SI INC SI ; SI pointed to next value CMP AX, WORD PTR [SI] ; Compare two values JNC L2 ; If AX > [SI] then go to test next value MOV AX, WORD PTR [SI] ; Else bring the large value to AX L2: LOOP L1 ; Continue to test next remaining values MOV LARGE, AX ; Store the largest value INT 03H ; Break point MYCODE ENDS END START

authorStream Live Help