Full Transcript

Computer Science Dept. Department Computer Science :‫القسم‬ Subject Name: Microprocessors - (1) : ‫أسم المادة‬ Year of Study: 2023-2024 :‫السنة الدراسية‬ Term: Second T...

Computer Science Dept. Department Computer Science :‫القسم‬ Subject Name: Microprocessors - (1) : ‫أسم المادة‬ Year of Study: 2023-2024 :‫السنة الدراسية‬ Term: Second Term :‫الفصل الدراسي‬ Email [email protected] Email Instructor Name: Ali Saadoon Ahmed :‫أسم التدريسي‬ Ali Saadoon Ahmed Al-Maaref University College Microprocessors OUTLINE What are logic gates Let’s do an example Types of Logic Gates! Number System Decimal Number System Binary Number System Why Binary? Octal Number System Hexadecimal Number System Relationship between Hexadecimal, Octal, Decimal, and Binary Number Conversions 2 WHAT ARE LOGIC GATES? Logic gates are the switches that turn ON or OFF depending on what the user is doing! They are the building blocks for how computers work. 3 WHAT ARE LOGIC GATES? Logic gates turn ON when a certain condition is true, and OFF when the condition is false They check whether or not the information they get follows a certain rule They either spit out the answer true (ON) or false (OFF) Remember: - True= ON = 1 - False = OFF=0 4 LET’S DO AN EXAMPLE Let’s say a certain logic gate needs to determine if two numbers are equal We learned before that computers only think of things in terms of ON and OFF, which to them is 1 and 0 Reminder: Input refers to the information you give the logic gate, and output refers to what it spits out! Let’s try this example, keeping this rule in mind! 5 TYPES OF LOGIC GATES! 6 TYPES OF LOGIC GATES! 7 TYPES OF LOGIC GATES! 8 DECIMAL NUMBER SYSTEM It consist of ten digit i.e., 0, 1, 2, 3, 4, 5, 6, 7, 8,9 with the base 10. Each number can be used individually, or they can be grouped to form a numeric value as 85,48,35,456 etc. The Binary Number System consist of only two digits– 0 and 1. Since this system use two digits, it has the base 2. All digital computer use this number system and convert the data input from the decimal format into its binary equivalent. 9 OCTAL NUMBER SYSTEMS In the Octal Number System, it consist of 8 digits i.e., 0, 1, 2, 3, 4, 5, 6, 7 with a base 8. The sequence of octal number goes as 0, 1, 2,3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 20, 21, 22, …..as go on. See each successive number after 7 is a combination of two or more unique symbols of octal system. 10 HEXADECIMAL NUMBER SYSTEM The Hexadecimal system use base 16. It has 16 possible digit symbol. It use the digit 0 through 9 plus the letters A, B, C, D, E, and F as the 16 digit symbols. 11 RELATIONSHIP BETWEEN HEXADECIMAL, OCTAL, DECIMAL, AND BINARY 12 DECIMAL-TO-BINARY CONVERSIONS The method of converting Decimal to binary is repeated-division method. For conversion follow the rules: 1. Divide the given decimal number with the base 2. 2. Write down the remainder and divide the quotient by 2. 3. Repeat step 2 till the quotient is zero. 13 DECIMAL-TO-BINARY CONVERSIONS 14 BINARY-TO-DECIMAL CONVERSION To convert a binary number, follow the steps: 1. Multiply each binary number with 2 having the power 0 for last position, starting from the right digit. 2. Increase the power one by one, with base as 3. Sum up all the products to get decimal number. 15 BINARY-TO-DECIMAL CONVERSION 16 DECIMAL-TO-OCTAL The method of converting Decimal to Octal is repeated-division method. For conversion follow the rules: 1. Divide the given decimal number with the base 8, 2. Write down the remainder and divide the quotient by 8, 3. Repeat step 2 till the quotient is zero. 17 DECIMAL-TO-OCTAL 18 OCTAL-TO-DECIMAL CONVERSION To convert a octal number follow the steps: 1. Multiply each Octal number with 8 having the power 0 for last position, starting from the right digit. 2. Increase the power one by one, with base as 8. 3. Sum up all the products to get decimal number. 19 OCTAL-TO-DECIMAL CONVERSION 20 OCTAL-TO-BINARY CONVERSION The conversion from octal to binary is performed by converting each octal digit to its 3-bit binary equivalent. 21 BINARY-TO-OCTAL CONVERSION 22 DECIMAL-TO-HEXADECIMAL CONVERSION The method of converting Decimal to Hexadecimal is repeated- division method. For conversion follow the rules: 1. Divide the given decimal number with the base 16. 2. Write down the remainder and divide the quotient by 16. 3. Repeat step 2 till the quotient is zero. 23 DECIMAL-TO-HEXADECIMAL CONVERSION 24 HEXADECIMAL-TO-DECIMAL CONVERSION To convert a Hexadecimal number, follow the steps: 1. Multiply each hexadecimal number with 16 having the power 0 for last position, starting from the right digit. 2. Increase the power one by one, with base as 16. 3. Sum up all the products to get decimal number. 25 HEXADECIMAL-TO-DECIMAL CONVERSION 26 BINARY-TO-HEXADECIMAL CONVERSION 27 HEXADECIMAL-TO-BINARY CONVERSION 28 Computer Science Dept. THANK YOU By: Ali Saadoon Ahmed 29 Computer Science Dept. Department Computer Science :‫القسم‬ Subject Name: Microprocessors - (2) : ‫أسم المادة‬ Year of Study: 2023-2024 :‫السنة الدراسية‬ Term: Second Term :‫الفصل الدراسي‬ Email [email protected] Email Instructor Name: Ali Saadoon Ahmed :‫أسم التدريسي‬ Ali Saadoon Ahmed Al-Maaref University College Microprocessors What is a Computer Architecture? Important Words: Computer element OUTLINE Measures of capacity and speed Computer level steps 2 WHAT IS A COMPUTER ARCHITECTURE? ✓Computer Architecture: Computer architecture is a science or a set of rules stating how computer software and hardware are joined together and interact to make a computer work. It not only determines how the computer works but also of which technologies the computer is capable. ✓Computer Architecture and Organization : The way of hardware are connected together to form a computer. 3 IMPORTANT WORDS: 4 THE COMPUTER CONSISTS OF THREE MAIN SUB-SYSTEM: 1. Central Processing Unit (CPU): Also simply called as the microprocessor acts as the brain coordinating all activities within a computer. 2. The Memory: The program instructions and data are primarily stored. 3. The Input/output (I/O) Devices: Allow the computer to input information for processing and then output the results. I/O Devices are also known as computer peripherals. 5 COMPUTER ELEMENT 1- Memory ▪ Stores both program and data(Permanent, temporary) 2- Control Unit ▪ Directs the operations of the other units by providing timing and control signals. 3- ALU ▪ Performs arithmetic and logical operations such as addition, subtraction, multiplication and division. 6 COMPUTER ELEMENT 4- Input ▪ An input device gets data from users ▪ Examples are keyboards, mice, webcams, microphones, and secondary storage devices (hard disks, floppy disks, CD–ROMs etc). 5- Output ▪ An output device sends data to users. ▪ Typical output devices are monitors, printers, modems, and secondary storage devices. 7 MEMORY SUBSYSTEM Memory also called RAM(Random Access Memory) consists of many memory cells(Storage Unites) of a fixed size. ❖ There are two important things in RAM: 1- Memory Width(W) ▪ How many bits is each memory cell, Typically one byte(=8bits). 2- Address width(N): ▪ How many bits used to represent each address, determines the maximum memory size=address space. 8 MEASURES OF CAPACITY AND SPEED Kilo- (K) = 1 thousand = 10^3 and 2^10 Mega- (M) = 1 million = 10^6 and 2^20 Giga- (G) = 1 billion = 10^9 and 2^30 Tera - (T) = 1 trillion = 10^12 and 2^40 Peta - (P) = 1 quadrillion = 10^15 and 2^50 9 PROCESSOR SPEEDS & MEMORY SIZE ❖ Hertz = clock cycles per second (frequency) 1MHz = 1,000,000Hz 1GHz = 1000 MHz – Processor speeds are measured in MHz or GHz. ❖ Byte = a unit of storage 1KB = 2^10 = 1024 Bytes 1MB = 2^20 = 1,048,576 Bytes – Main memory (RAM) is measured in MB --Disk storage is measured in GB for small systems, TB for large systems. 10 MEASURES OF TIME AND SPACE Millie- (m) = 1 thousandth = 10 ^-3 Micro- (μ) = 1 millionth = 10^ -6 Nano- (n) = 1 billionth = 10^ -9 Pico- (p) = 1 trillionth = 10 ^-12 Femto- (f) = 1 quadrillionth = 10^ -15 11 COMPUTER LEVEL STEPS Level 6: The User Level: - Program execution and user interface level. - The level with which we are most familiar. Level 5: High-Level Language Level: – The level with which we interact when we write programs in languages such as C, Pascal and Java. Level 4: Assembly Language Level: - Acts upon assembly language produced from Level 5, as well as instructions programmed directly at this level. 12 COMPUTER LEVEL STEPS Level 3: System Software Level: Controls executing processes on the system. Protects system resources. Assembly language instructions often pass through Level 3 without modification. Level 2: Machine Level: Also known as the Instruction Set Architecture (ISA) Level. Consists of instructions that are particular to the architecture of the machine. Programs written in machine language need no compilers, interpreters, or assemblers. 13 COMPUTER LEVEL STEPS Level 1: Control Level: A control unit decodes, executes instructions and moves data through the system. Control units can be micro programmed or hardwired. A micro program is a program written in a low level language that is implemented by the hardware. Hardwired control units consist of hardware that directly executes machine instructions. Level 0: Digital Logic Level: This level is where we find digital circuits (the chips). Digital circuits consist of gates and wires. These components implement the mathematical logic of all other levels. 14 Computer Science Dept. THANK YOU By: Ali Saadoon Ahmed 15 Computer Science Dept. Department Computer Science :‫القسم‬ Subject Name: Microprocessors - (3) : ‫أسم المادة‬ Year of Study: 2023-2024 :‫السنة الدراسية‬ Term: Second Term :‫الفصل الدراسي‬ Email [email protected] Email Instructor Name: Asst. Lect. Ali Saadoon Ahmed :‫أسم التدريسي‬ Asst. Lect. Ali Saadoon Ahmed Al-Maaref University College Microprocessors Microcomputers and Microprocessors Evolution of Intel 8086 Family OUTLINE Microprocessors Pipelining and Registers Introduction to Assembly Programming 2 MICROCOMPUTERS AND MICROPROCESSORS There are three major parts of a Computer System. 1. Central Processing Unit (CPU): Also simply called as the microprocessor acts as the brain coordinating all activities within a computer. 2. The Memory: The program instructions and data are primarily stored. ❖8085 has A Max. memory capacity of 64 KB, while 8086 has Max. memory 1 MB. 3. The Input/output (I/O) Devices: Allow the computer to input information for processing and then output the results. I/O Devices are also known as computer peripherals. 3 MICROCOMPUTERS AND MICROPROCESSORS The CPU is connected to memory and I/O devices through a strip of wires called a bus. The bus inside a computer carries information from place to place. In every computer there are three types of busses: 1. Address Bus: The address bus is used to identify the memory location or I/O device the processor intends to communicate with. The width of the Address Bus rages from 20 bits (8086) to 36 bits for (Pentium II). MICROCOMPUTERS AND MICROPROCESSORS 2. Data Bus: Data bus is used by the CPU to get data from User to send data to the memory or the I/O devices. The width of a microprocessor is used to classify the microprocessor. The size of data bus of Intel microprocessors vary between 8-bit (8085) to 64-bit (Pentium). 3. Control Bus. How can we tell if the address on the bus is memory address or an I/O device address? This where the control bus comes in. Each time the processor outputs an address it also activates one of the four control bus signals: Memory Read, Memory Write, I/O Read and I/O Write. ❖The address and control bus contains output lines only, therefore it is unidirectional, but the data bus is bidirectional 5 MICROCOMPUTERS AND MICROPROCESSORS There two types of memory used in microcomputers: RAM (Random Access Memory/ Read-Write memory): is used by the computer for the temporary storage of the programs that is running. Data is lost when the computer is turned off. So known as volatile memory. ROM (Read Only Memory): the information in ROM is permanent and not lost when the power is turned off. Therefore, it is called nonvolatile memory. Note that RAM is sometimes referred as primary storage, where magnetic /optical disks are called secondary storage. 6 MICROCOMPUTERS AND MICROPROCESSORS 7 MICROCOMPUTERS AND MICROPROCESSORS Inside the CPU: A program stored in the memory provides instructions to the CPU to perform a specific action. This action can be a simple addition. It is function of the CPU to fetch the program instructions from the memory and execute them. 1. The CPU contains a number of registers to store information inside the CPU temporarily. Registers inside the CPU can be 8-bit, 16-bit, 32-bit or even 64-bit depending on the CPU. 2. The CPU also contains Arithmetic and Logic Unit (ALU). The ALU performs arithmetic (add, subtract, multiply, divide) and logic (AND, OR, NOT) functions. 8 MICROCOMPUTERS AND MICROPROCESSORS Inside the CPU: 3. The CPU contains a program counter also known as the Instruction Pointer to point the address of the next instruction to be executed. 4. Instruction Decoder is a kind of dictionary which is used to interpret the meaning of the instruction fetched into the CPU. Appropriate control signals are generated according to the meaning of the instruction. 9 MICROCOMPUTERS AND MICROPROCESSORS 10 Internal block diagram of a CPU MICROCOMPUTERS AND MICROPROCESSORS 11 EVOLUTION OF INTEL 80X86 FAMILY MICROPROCESSORS 12 PIPELINING AND REGISTERS Pipelining In the 8085 microprocessor, the CPU could either fetch or execute at a given time. CPU had to fetch an instruction from the memory, then execute it, then fetch again and execute it and so on.. Pipelining is the simplest form to allow the CPU to fetch and execute at the same time. Note that the fetch and execute times can be different. 13 PIPELINING AND REGISTERS Registers of 8086 Microprocessor In the CPU, registers are used store information temporarily. The information can be one or two bytes of data, or the address of data. In 8088/8086 general-purpose registers can be accessed as either16-bit or 8-bit registers. All other registers can be accessed as full 16-bit registers. 14 PIPELINING AND REGISTERS Different registers are used for different functions. Registers will be explained later within the context of instructions and their applications. The first letter of each general register indicates its use. AX is used for the Accumulator. BX is used for Base Addressing Register. CX is used for Counter Loop Operations. DX is used to point out data in I/O 15 operations. INTRODUCTION TO ASSEMBLY PROGRAMMING Low / High level languages: Assembly Language is a low-level language. Deals directly with the internal structure of CPU. Assembler translates Assembly language program into machine code. In high-level languages, Pascal, Basic, C; the programmer does not have to be concerned with internal details of the CPU. Compilers translate the program into machine code. 16 INTRODUCTION TO ASSEMBLY PROGRAMMING 17 INTRODUCTION TO ASSEMBLY PROGRAMMING 18 INTRODUCTION TO PROGRAM SEGMENTS Assembly Language Program consists of three segments: Code Segment : contains the program code (instructions) Data Segment : used to store data (information) to be processed by the program Stack Segment: used to store information temporarily. 19 Computer Science Dept. THANK YOU By: Asst. Lect. Ali Saadoon Ahmed 20 Computer Science Dept. Department Computer Science :‫القسم‬ Subject Name: Microprocessors - (4) : ‫أسم المادة‬ Year of Study: 2024-2023 :‫السنة الدراسية‬ Term: First Term :‫الفصل الدراسي‬ Email [email protected] Email Instructor Name: Ali Saadoon AHMED :‫أسم التدريسي‬ Ali Saadoon AHMED Al-Maaref University College Microprocessors Computer parts How a program execute in a computer. Introduction to computer system. Microprocessor elements Microprocessor Basic Operations. 8086 Functional Units Execution Unit EU OUTLINE Bus Interface Unit BUI 2 COMPUTER PARTS 3 COMPUTER PARTS 4 HOW A PROGRAM EXECUTE IN A COMPUTER A Program in computer consists of two; first is the source code, other is the object code. Source code is the version of a computer program as it is originally written i.e. typed into a computer by a programmer in a programming language. 5 HOW A PROGRAM EXECUTE IN A COMPUTER A compiler is a specialized program that converts source code into object code and it converts the whole program at a time. The object code is a machine code, also called a machine language, which can be understood directly by a specific type of CPU. So the Object code is the code which is executed by the compiler and is then sent for execution. 6 HOW A PROGRAM EXECUTE IN A COMPUTER A machine code file can be immediately executable i.e. runnable as a programmer it might require linking with other object code files e.g. libraries to produce a complete executable program. Thus object code is simply the machine language output of a compiler that is ready for execution on a particular computer and an object file format is a format that is used for the storage of object code and related data produced by a compiler 7 HOW A PROGRAM EXECUTE IN A COMPUTER An object code file can contain not only the object code, but also relocation information that the linker uses to assemble multiple object files to form an executable program. It can also contain other information, such as program symbols and debugging information. 8 INTRODUCTION TO COMPUTER SYSTEM 9 INTRODUCTION TO COMPUTER SYSTEM Micro Computers (Micros): are small computer systems driven by a microprocessor chip, they designed to be used by one person at a time, commonly called personal computers (PCs). Microprocessor: (physically) is a digital integrated circuit (IC) that can be programmed with a series of instructions to perform various operations on data. A microprocessor is the CPU of a computer. It can do arithmetic and logic operations, move data from one place to another, and make decisions based on certain instructions. 10 MICROPROCESSOR ELEMENTS A MP (logically) consists of several units, each designed for a specific task. The design and organization of these units are called architecture. 11 MICROPROCESSOR ELEMENTS ALU: (Arithmetic Logic Unit) which perform arithmetic operations like addition, subtraction, multiplication and division) and logic operations like (NOT, AND, OR, X-OR), as well as many other types of operations. ALU obtains data from the registers. Instruction Decoder: it translates the programming instruction into an address where microcode resides for executing the instruction. Control Unit: (CU) it provides the timing and control signals for getting data into and out of the MP. 12 MICROPROCESSOR ELEMENTS Register set (array): It is a collection of registers that are contained within the microprocessor. Data and memory addresses are temporarily stored in these registers during the execution of a program. The registers work very quickly making the program run more efficiently. GPR: General-Purpose Register, meaning they can be used for multiple purposes and assigned to a variety of functions by the programmer. SPR: they have specific capacities and functions; they can’t be used as GPR by the data user. Flags: they used to hold processor status. These bits (flags) are set by the CPU as the result of the execution of an operation. The status bits can be tested at a later time as part of another operation. 13 MICROPROCESSOR BUSES Three buses for microprocessors allow data, addresses and instructions to be moved. 14 MICROPROCESSOR BUSES 1. The data bus: It is a bi-directional bus that connects the CPU, memory, and the other hardware devices on the motherboard. The number of wires in the bus affects the speed at which data can travel between hardware components. For example an 8-wire bus can move 8 bits at a time, which is a full byte. A 16-bit bus transfer 2 bytes, and a 32-bit bus can transfer 4 byte at a time because each wire can transfer 1 bit of data at a time. 15 MICROPROCESSOR BUSES 2. The address bus: It is a one-directional bus that connects only the CPU and RAM and carries only memory address. The address bus used by the MP to specify the number of locations (words) in memory. For example if the address bus of a MP is 16 lines then it has 2^16 unique locations in memory ( 0 – 2^16 - 1). 16 MICROPROCESSOR BUSES The control bus: It is a bi-directional bus used by MP to coordinates its operations and carrying control signal (either write signal or read signal). Also control bus can carrying timing signals. 17 MICROPROCESSOR BASIC OPERATIONS A microprocessor executes a program by repeatedly cycling through following three basic steps: 1- Fetch an instruction from main memory and place it in the CPU The contents of the PC are transferred to MAR. The main memory is accessed and the current instruction is fetched into MDR. The operation code is transferred from MDR to IR where it is decoded. 18 MICROPROCESSOR BASIC OPERATIONS 2- Decodes the instruction; if other information is required by the instruction, fetch the other information. Op-code (operation code) of the instruction is decoded. Contents of PC are incremented by 1(in case of 1 byte instruction or equal to the no. of bytes of the instruction currently being executed.) 19 MICROPROCESSOR BASIC OPERATIONS 3. Execute the instruction and store the results. Execute the instruction Store the results in the proper place (go to the fetch phase to begin executing the next instruction). 20 8086 - FUNCTIONAL UNITS The internal architecture of Intel 8086 is divided into 2 units: The Execution Unit (EU), and The Bus Interface Unit (BIU). A. EU (Execution Unit) The main components of the EU are General purpose registers, the ALU, Special purpose registers, the Instruction Register and Instruction Decoder, and the Flag/Status Register. The main functions of the EU are as follows: 1- Fetching instructions from the Queue in BIU, decodes, and executes arithmetic and logic operations using the ALU. 2- Sending control signals for internal data transfer operations within the microprocessor (Control Unit). 3- Sending request signals to the BIU to access the external module. 4- It operates with respect to T-states (clock cycles) and not machine cycles. EU has no direct connection with system buses as shown in the figure on the next page, it performs operations over data through BIU. 21 B. BIU (BUS INTERFACE UNIT) BIU mainly contains a pre-fetch queue, the 4 Segment registers, the Instruction Pointer, and an Address Generation Circuit. Provides the interface of 8086 to external memory and I/O devices via the System Bus. Performs various machine cycles such as memory read/write, I/O read, etc. to transfer data between memory and I/O devices. Generates the 20-bit physical address for memory access. Takes care of all data and address transfers on the buses for the EU Such as sending addresses, fetching instructions from the memory, and reading data from the ports and the memory. Writing data to the ports and the memory. EU has no direct connection with System Buses, so this is possible with the BIU. Both EU and BIU are connected with the Internal Bus. 22 Computer Science Dept. THANK YOU By: Ali Saadoon AHMED 23 Computer Science Dept. Department Computer Science :‫القسم‬ Subject Name: Microprocessors - (5) : ‫أسم المادة‬ Year of Study: 2023-2024 :‫السنة الدراسية‬ Term: First Term :‫الفصل الدراسي‬ Email [email protected] Email Instructor Name: Ali Saadoon Ahmed :‫أسم التدريسي‬ Ali Saadoon Ahmed Al-Maaref University College Microprocessors OUTLINE ❖ Register Organization ❖ Introduction to Assembly Programming ❖ Data Transfer Instructions In 8086 Microprocessor ❖ Arithmetic instruction ❖ Segment Addressing. ❖ Logical address and Physical address: 2 Data Transfer Instructions In 8086 Microprocessor Register Organization The 8086 has a powerful set of registers. It includes general purpose registers, segment registers, pointers and index registers, and flag register. The register organization of 8086. The registers shown are accessible to programmer. As shown in the Fig, all the registers of 8086 are 16-bit registers. 3 Assembly Programming Each personal computer has a microprocessor that manages the computer's arithmetical, logical, and control activities. The Environment Used ❖ EMU8086 - MICROPROCESSOR EMULATOR 4 Data Transfer Instructions In 8086 Microprocessor ❖ Data transfer instructions are the instructions that transfer data in the microprocessor. They are also called copy instructions. Types of Data transfer instructions : 1. Move instructions: These instructions are used to move data from one memory location to another or between a memory location and a register. MOV instruction MOV destination, source; copy source operand to destination 5 Data Transfer Instructions In 8086 Microprocessor MOV instruction Example: (8-bit ) MOV CL,55H ;move 55H into register CL MOV DL,CL ;move/copy the contents of CL into DL (now DL=CL=55H) MOV BH,DL ;move/copy the contents of DL into BH (now DL=BH=55H) MOV AH,BH ;move/copy the contents of BH into AH (now AH=BH=55H) Example: (16-bit) MOV CX,468FH ;move 468FH into CX (now CH =46 , CL=8F) MOV AX,CX ;move/copy the contents of CX into AX (now AX=CX=468FH) MOV BX,AX ;now BX=AX=468FH MOV DX,BX ;now DX=BX=468FH MOV DI,AX ;now DI=AX=468FH MOV SI,DI ;now SI=DI=468FH MOV DS,SI ;now DS=SI=468FH MOV BP,DS ;now BP=DS=468FH 6 Data Transfer Instructions In 8086 Microprocessor These types of operands are Supported: mov REG, memory mov memory, REG mov REG, REG Note: mov memory, immediate REG: AX, BX, CX, DX, AH, AL, BH, BL, CH, CL, DH, DL, DI, SI, BP, SP. mov REG, immediate Immediate: 5, 24, 3FH, 1000101B, etc mov SREG, memory MEMORY: [BX], [SI] +BX, [DI] +BX, etc… mov memory, SREG mov REG, SREG mov SREG, REG The MOV instruction cannot: 1- Set the value of the CS and IP registers. 2- Copy value of one segment register to another segment register (should copy to general register first). 3- Copy immediate value to segment register (should copy to general register first). 7 Data Transfer Instructions In 8086 Microprocessor 8 Data Transfer Instructions In 8086 Microprocessor XCHG INSTRUCTION used to exchange (swap) data between two general-purpose registers or between a general-purpose register and a storage location in memory. The forms of the XCHG instruction and its allowed operands are shown in Figures below: 9 Arithmetic instruction The instruction set of the 8086 microprocessor contains a variety of arithmetic instructions. They include instructions for the addition, subtraction, multiplication, and division operations. These operations can be performed on numbers expressed in a variety of numeric data formats. Addition instruction: ADD, INC, DEC ADD instruction: The ADD instruction is used to add the contents of a source operand to the contents of the destination operand. The result is put into the location of the destination operand. In general, the result of executing ADD is expressed as: ADD Destination, Source 10 Arithmetic instruction Addition instruction Ex: Assume that AX and BX registers contain 1100H and 0ABCH, respectively. What is the result of executing the instruction? ADD AX, BX The content of the source (BX) will be added to the content of the destination (AX) to give 0ABC+ 1100 = 1BBC in the destination AX. The process of executing this instruction is shown in the following figures. 11 Arithmetic instruction INC instruction It increments the byte or word by one. ❖ The INC instruction adds 1 to any register or memory location, except a segment register. ❖ The operand can be a register or memory location. Example: INC AX; adds 1 to AX register INC DX; adds 1 to DX register DEC instruction Example: DEC AX; SUB 1 to AX register DEC DX; SUB 1 to DX register 12 Arithmetic instruction SUB instruction: The subtract (SUB) instruction is used to subtract the value of a source operand from a destination operand. The result of this operation in general is given as (Destination) - (Source) → (D) ❖ Immediate Subtraction Immediate subtraction is employed whenever constant or known data are subtracted. Example: MOV CH, 22H SUB CH, 44H The subtraction is stored in the CH register. ❖ Memory-to-Register Subtraction Moves memory data to be subtracted to a register. Example: MOV DI, OFFSET NUMB MOV AL, 0 SUB AL, [DI] 13 SUB AL, [DI+1] Arithmetic instruction SUB instruction: Instructions MUL: The 8086 multiply instructions have the general forms MUL SOURCE 8-Bit Multiplication Example-Assembly Language Program MOV AL, 5H ; a byte is moved to AL MOV BL, 10H ; immediate data must be in BL register 14 MUL BL Arithmetic instruction Instructions MUL: 16-Bit Multiplication Example-Assembly Language Program The following statements multiply the 16-bit value 2000H by 0100H. The Carry flag is set because the upper part of the product (located in DX) is not equal to zero: MOV AX, 2000H ; a word is moved to AX MOV BX, 0100H ; immediate data must be in BX register MUL BX 15 Arithmetic instruction Instructions DIV: Q: Write an assembly language program to compute C=(5/9)*(F-32) MOV AX,05 MOV BX,09 DIV BX MOV BX,0FH MOV CX, 32H SUB BX,CX MUL BX RET 16 Arithmetic instruction Instructions DIV: Q: Write an assembly language program to compute C=(5/9)*(F-32) MOV AX,05 MOV BX,09 DIV BX MOV BX,0FH MOV CX, 32H SUB BX,CX MUL BX RET 17 SEGMENT ADDRESSING A segment is an area of memory that includes up to 64K bytes and begins on an address evenly divisible by 16. The segment size of 64K bytes came because the 8085 microprocessor could address a maximum of 64k Bytes of physical memory since it had only 16 pins for the address lines (2^16=64K). Whereas in the 8085 there was only 64K bytes of memory for all code, data and stack information. For this reason, the 8086/88 microprocessor can only handle a maximum of 64K bytes of code and 64K bytes of data and 64K bytes of stack at any given time. 18 SEGMENT ADDRESSING MPU 8086 19 LOGICAL ADDRESS AND PHYSICAL ADDRESS: The BIU contains a dedicated Adder which is used to generate the 20 bits physical address that is out put on the address bus. This address is formed by adding the 16-bit shifting segment address with the offset address. Segment*10H 20 LOGICAL ADDRESS AND PHYSICAL ADDRESS: Segment address: It is located with one of the segment register and defines the beginning address of any 64 KB memory segment. Offset address: is a location within a 64 KB segment range, therefore, an offset address can range from 0000 – FFFF. Logical address: consists of a segment value and offset address. Sometimes the segment and offset is written as (segment: offset). 21 LOGICAL ADDRESS AND PHYSICAL ADDRESS: The different combination used in 8086 MP for Segment: offset address shown in table below 22 LOGICAL ADDRESS AND PHYSICAL ADDRESS: 23 LOGICAL ADDRESS AND PHYSICAL ADDRESS: Example1: If CS=24F6h and IP=634Ah, show: a- The Logical address and the offset address. b- calculate the physical address. c- calculate the lower range and upper range of the code segment. Sol: a- 24F6:634A, the offset is 634A b- PA= 24F60+634A PA=2B2AA c- The lower range 24F60+0000=24F60 The upper range of the code segment is 24F60+FFFF=34F5F 24 LOGICAL ADDRESS AND PHYSICAL ADDRESS: Example2: If DS = 7FA2h and the offset is 438Eh, show: a- The logical address, and calculate : b- The physical address. c- The lower range and upper range of the code segment. Sol: a- 7FA2:438E b- PA= 7FA20+438E=83DAE c- The lower range 7FA20+0000=7FA20 The upper range of the code segment is 7FA20+FFFF=8FA1F 25 Computer Science Dept. THANK YOU By: Ali Saadoon Ahmed 26

Use Quizgecko on...
Browser
Browser