Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microprocessors used in Personal Computers. The Memory Map of a Personal Computers Transient Program Area (TPA): Holds the operating system (interrupt.

Similar presentations


Presentation on theme: "Microprocessors used in Personal Computers. The Memory Map of a Personal Computers Transient Program Area (TPA): Holds the operating system (interrupt."— Presentation transcript:

1 Microprocessors used in Personal Computers

2 The Memory Map of a Personal Computers Transient Program Area (TPA): Holds the operating system (interrupt vectors, DOS BIOS, devices drivers, Command.com) and application programs. System Area: Holds the ROM BIOS, the video buffer area, and the BASIC language ROM. Extended Memory: Memory above the 1M conventional memory found in AT compatible computers. Its size depends on the RAM installed on the motherboard, and is limited by the size of the processor’s address bus.

3 The 80x86 Programming Model

4 The Flag Register Z (zero): This flag is set to one if the result of the last arithmetic or logic instruction is zero. S (sign): This flag is set to one if the MSBit of the result of the last arithmetic or logic instruction is one, indicating a negative number. C (carry): This flag is set to one if the last arithmetic instruction gave a carry out or a borrow in. O (overflow): This flag is set to one if the result of the last arithmetic operation on signed numbers exceeded the capacity of the destination register.

5 80x86 Modes of operation Protected mode –Programs are given separate memory areas (segments) –Programs are not allowed to access memory outside of their segments Real-address mode –Environment of 8086 processor –Direct access to system memory and hardware devices –The operating system could crash System management mode –Provides an operating system for implementing power management and system security functions (computer manufacturers)

6 Segmentation Segmentation is used to allow relocation of programs, i.e. programs can be loaded on different memory areas and still run correctly. Segmentation is used in the 8088/8086 microprocessors to allow the generation of 20-bit addresses using 16-bit registers. In the Real Mode Operation a 20-bit address (effective address) is obtained by shifting the segment address 4 bits to the left (X10H) and then adding the offset address. The offset address is specified in the program. The segment address is specified by the operating system whenever the program is loaded. The code segment holds the machine codes of the program.The Instruction Pointer specifies the offset address in the code segment. The data segment holds the data used by the program. Most data references are specified in the data segment. The stack segment holds the stack of the program. The offset address in the stack segment is specified with the registers SP and BP. The extra segment is used as a data segment by some data movement instructions.

7 Segmentation (Example) If DS =1600H find the maximum area occupied by the data segment. Find also the effective address, if the offset address is 1F00H. Starting address = DS X 10H = 1600H X 10H = 16000H Ending address = Starting address + FFFF = 16000H + FFFFH = 25FFFH Effective address= Segment:Offset = 1600:1F00 = Segment address X 10H + Offset = 1600H X 10H + 1F00H = 16000H + 1F00H = 17F00H

8 Assembler Directives  Directives are instructions given by the programmer to the assembler on how to assemble the program.  Directives are not part of the instruction set of the microprocessor.  The use of directives might vary from assembler to assembler.  Some of the MASM 6.12 assembler directives are: –ORG (Origin): Tells the assembler where to store the machine code of the next instruction. –EQU (Equate): Tells the assembler to assign a value to an identifier. –SEGMENT: Tells the assembler to begin a new segment. –ASSUME: Tell the assembler to associate a segment with a segment register. –PROC (Procedure): Tells the assembler to begin a new procedure. –MACRO: Assigns the sequence of instructions to an identifier. –END: Ends a program, segment (ENDS), a procedure (ENDP), or a macro (ENDM).

9 Data Definition Directives Data Definition directives tell the assembler to store the specified data in the next memory locations. Data that occupies more than one location is stored with the LSByte in the lower address. –(DB) Define Byte (1 byte or 8 bits - Same as BYTE) –(DW) Define Word (2 bytes or 16 bits - Same as WORD) –(DD) Define Double Word (4 bytes or 32 bits - Same as DWORD) –(DQ) Define Quad Word (8 bytes or 64 bits - Same as QWORD) –(DT) Define Ten Bytes (10 bytes or 80 bits - Same as TBYTE) Examples: ABCDB26H;ABC=26H XYZDB35H,87H,0A4H;XYZ= {35H,87H,A4H} YOU DB ‘ JOHN ’ ;YOU = ‘ JOHN ’ VALDW1254H;VAL = 1254H X1DB?;X1 = UNSPECIFIED X4DB 3 DUP(20H);X4 = {20H,20H,20H} N1DB123H;INVALID

10 Data Definitions (Example) Show the content of the memory based on the following data definitions: ORG 100H VAL1EQU21H AB10DB37 NEWDB23H,56H, ’ $ ’ LOTDW1245H XY11DB ‘ NEXT ’ A123DD123H B561DB4 DUP(40H) VAL2DBVAL1

11 Format of DOS programs All programs must have a code and a stack. –Code is the part of the program that contains the instructions of the program. –Stack is an area in the RAM used by the system to store return addresses, and by the programmer to store temporarily data. It is a Last In First Out (LIFO) buffer. Programs can also have a data area, where all data (variables) is stored. There are two basic types of programs: –Commands (.COM). The data and the stack of the program are part of the Code segment. The stack is always located at the end of the segment. The first 256 bytes of the segment are reserved. –Executable (.EXE). The code and stack and data of the program are located in different segments.

12 Format of the.COM programs CSEGSEGMENT PARA 'CODE’;Start a Code segment ASSUME CS:CSEG, DS:CSEG, SS:CSEG ORG 100H;Reserve first 256 locations START:JMP MAIN;Skip data area {Place the data of the program here} MAINPROCNEAR;Beginning of main procedure {Place the code of the program here} RET;Get return DOS address MAINENDP;End of main procedure CSEGENDS;End of the segment END START;End of the program

13 Addressing Modes Addressing mode refers to the way the data needed by an instruction is specified.

14 Immediate Addressing Mode The data needed is specified as a number in the machine code of a program. The data is specified by the programmer: –as a numeric operand in the instruction, e.g.MOVAL,87H;AL  87H MOVCX,34A6H;CX  34A6H MOVBL,8C2H;Invalid (Data Mismatch) –or as a label. The actual value is determined by the assembler. e.g.MOVBX,OFFSET VAL3;BX  Address of VAL3 MOV AH,CON1;AH  CON1

15 Immediate Addressing Mode (Example)

16 Register Addressing Mode Both of the operands are the contents of registers. e.g.MOVAL,BH;AL  BH MOVBX,CX;BX  CX MOVAX,DL;Invalid (Data Mismatch) Example :

17 Direct Addressing Mode One of the operands is the contents of the memory location that is specified directly in the instruction. e.g.MOVAL,[1008H];AL  [1008H] MOVBX,VALUE;BX  [VALUE]

18 Register Indirect Addressing Mode One of the operands is the contents of the memory location that is specified by a register, or a combination of registers and an offset, in the instruction.  Index: Use of SI or DI to specify a memory location. e.g.MOVAL,[SI];AL  [SI] -Base: Use of BX or BP to specify a memory location. e.g.MOVAH,[BP];AL  [BP] -Base Relative: Use of BX or BP in combination with an offset to specify a memory location. e.g.MOVAL,[BX+ 2];AL  [BX + 2] -Base Relative plus Index: Use of BX or BP in combination with an index register (SI or DI) and an offset to specify a memory location. e.g.MOVAL,[BX+SI+8];AL  [BX+SI+8] MOVBX,ARR[BX+DI];BX  ARR[BX+DI]

19 Register Indirect Addressing Mode (Example)

20 Addressing Modes (Example)

21 Examples Indicate whether or not each of the following MOV instructions is valid or invalid MOV AX,BX MOV DX,BL MOV ECX,EDX MOV SI,DI MOV DS,AX MOV AL,DH MOV AX,DH MOV IP,AX MOV SI,CL MOV EDX,AX MOV AX,ES MOV AX,16 MOV DX,7F65H MOV ECX,6F23458H MOV SI, -1 MOV DS,1000H MOV AL,100H MOV 123,DH MOV 0FABH,AX MOV SI, CL MOV EDX,ESI MOV EDX,-2


Download ppt "Microprocessors used in Personal Computers. The Memory Map of a Personal Computers Transient Program Area (TPA): Holds the operating system (interrupt."

Similar presentations


Ads by Google