PESIT Bangalore South Campus

Similar documents
Intel 8086: Instruction Set

LABORATORY WORK NO. 7 FLOW CONTROL INSTRUCTIONS

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

Assignment no:4 on chapter no :3 : Instruction set of 8086

EXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM

US06CCSC04: Introduction to Microprocessors and Assembly Language UNIT 3: Assembly Language Instructions II

3.1 DATA MOVEMENT INSTRUCTIONS 45

Code segment Stack segment

8086 INSTRUCTION SET

Experiment N o 8. String Handling Instructions

9/25/ Software & Hardware Architecture

Ex: Write a piece of code that transfers a block of 256 bytes stored at locations starting at 34000H to locations starting at 36000H. Ans.

Chapter Four Instructions Set

8086 ASSEMBLY LANGUAGE PROGRAMMING

SRI VENKATESWARA COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF ECE EC6504 MICROPROCESSOR AND MICROCONTROLLER (REGULATION 2013)

Week /8086 Microprocessor Programming II

8086 programming Control Flow Instructions and Program Structures

ADVANCE MICROPROCESSOR & INTERFACING

WINTER 12 EXAMINATION Subject Code : Model Answer Page No : / N. a) Describe the function of SID and SOD pins of 8085 microprocessor

CS401 Assembly Language Solved MCQS From Midterm Papers

Microprocessor. By Mrs. R.P.Chaudhari Mrs.P.S.Patil

db "Please enter up to 256 characters (press Enter Key to finish): ",0dh,0ah,'$'

CS-202 Microprocessor and Assembly Language

CS401 Assembly Language Solved Subjective MAY 03,2012 From Midterm Papers. MC

Marking Scheme. Examination Paper Department of CE. Module: Microprocessors (630313)

Lecture (08) x86 programming 7

EC 333 Microprocessor and Interfacing Techniques (3+1)

VARDHAMAN COLLEGE OF ENGINEERING (AUTONOMOUS) Shamshabad, Hyderabad

Data Movement Instructions

MICROPROCESSOR PROGRAMMING AND SYSTEM DESIGN

if 2 16bit operands multiplied the result will be

Intel Instruction Set (gas)

Week /8086 Microprocessor Programming

Marking Scheme. Examination Paper. Module: Microprocessors (630313)

Summer 2003 Lecture 4 06/14/03

X86 Addressing Modes Chapter 3" Review: Instructions to Recognize"

Selection and Iteration. Chapter 7 S. Dandamudi

Program controlled semiconductor device (IC) which fetches (from memory), decodes and executes instructions.

CG2007 Microprocessor systems.

8086 INTERNAL ARCHITECTURE

Ex : Write an ALP to evaluate x(y + z) where x = 10H, y = 20H and z = 30H and store the result in a memory location 54000H.

CSC 2400: Computer Systems. Towards the Hardware: Machine-Level Representation of Programs

Signed number Arithmetic. Negative number is represented as


Inline Assembler. Willi-Hans Steeb and Yorick Hardy. International School for Scientific Computing

EEM336 Microprocessors I. Data Movement Instructions

Arithmetic and Logic Instructions And Programs

CC411: Introduction To Microprocessors

Arithmetic Instructions

Intel 8086 MICROPROCESSOR ARCHITECTURE

Kingdom of Saudi Arabia Ministry of Higher Education. Taif University. Faculty of Computers & Information Systems

complement) Multiply Unsigned: MUL (all operands are nonnegative) AX = BH * AL IMUL BH IMUL CX (DX,AX) = CX * AX Arithmetic MUL DWORD PTR [0x10]

Module 3 Instruction Set Architecture (ISA)

CSC 8400: Computer Systems. Machine-Level Representation of Programs

Conditional Processing

Intel 8086 MICROPROCESSOR. By Y V S Murthy

EE2007 Microprocessor systems.

Basic Execution Environment

UNIT 4. Modular Programming

ASSEMBLY LANGUAGE PROGRAMMING OF THE MICROCOMPUTER

ORG ; TWO. Assembly Language Programming

UNIT 2 PROCESSORS ORGANIZATION CONT.

EXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM

APPENDIX C INSTRUCTION SET DESCRIPTIONS

Computer Organization & Assembly Language Programming. CSE 2312 Lecture 15 Addressing and Subroutine

Microprocessor and Assembly Language Week-5. System Programming, BCS 6th, IBMS (2017)

EC 333 Microprocessor and Interfacing Techniques (3+1)

IFE: Course in Low Level Programing. Lecture 6

Introduction to Microprocessor

Basic Assembly SYSC-3006

icroprocessor istory of Microprocessor ntel 8086:

Lab 6: Conditional Processing

BAHAR DÖNEMİ MİKROİŞLEMCİLER LAB4 FÖYÜ

Section 001. Read this before starting!

8088/8086 Programming Integer Instructions and Computations

Chapter 3: Addressing Modes

Assembling, Linking and Executing 1) Assembling: .obj obj .obj.lst .crf Assembler Types: a) One pass assembler:

Chapter 12. Selected Pentium Instructions

Q1: Multiple choice / 20 Q2: Protected mode memory accesses

Introduction to IA-32. Jo, Heeseung

UNIT III MICROPROCESSORS AND MICROCONTROLLERS MATERIAL OVERVIEW: Addressing Modes of Assembler Directives. Procedures and Macros

COMPUTER ENGINEERING DEPARTMENT

INTRODUCTION TO IA-32. Jo, Heeseung

SOEN228, Winter Revision 1.2 Date: October 25,

MPID MICROPROCESSOR AND ITS INTERFACING DEVICES EEE III II SEMESTER OBJECTIVE QUESTIONS

Assembly Language. Dr. Esam Al_Qaralleh CE Department Princess Sumaya University for Technology. Overview of Assembly Language

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Electronics and Communication

Hardware and Software Architecture. Chapter 2

Week /8086 Microprocessor Programming I

.code. lea dx,msg2. Page 1/8. Problem 1: Programming in Assembly [25 Points]

L1 Remember, L2 Understand, L3 - Apply, L4 Analyze, L5 Evaluate, L6 Create

6/20/2011. Introduction. Chapter Objectives Upon completion of this chapter, you will be able to:

Addressing Modes on the x86

6/29/2011. Introduction. Chapter Objectives Upon completion of this chapter, you will be able to:

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

Basic characteristics & features of 8086 Microprocessor Dr. M. Hebaishy

EC-333 Microprocessor and Interfacing Techniques

Logical and bit operations

Transcription:

INTERNAL ASSESSMENT TEST 2 Date : 02/04/2018 Max Marks: 40 Subject & Code : Microprocessor (15CS44) Section : IV A and B Name of faculty: Deepti.C Time : 8:30 am-10:00 am Note: Note: Answer any five complete questions one from each part,each of 8 marks PART 1 1. a)explain the syntax of the following instructions with an example for each: i) DAA: Decimal Adjust Accumulator. This instruction is used to convert the result of the addition of two packed BCD numbers to a valid BCD number. The result has to be only in AL. E.g. AL = 53 CL = 29 (5 Marks) ADD AL, CL ; AL 53 + 29=7C DAA ; AL 7C + 06 (as C>9),; AL 82 ii) MUL: Unsigned Multiplication Byte or Word. This instruction multiplies an unsigned byte or word by the contents of AL. E.g. MUL BH ; (AX) (AL) x (BH) MUL CX ; (DX)(AX) (AX) x (CX) MUL WORD PTR [SI] ; (DX)(AX) (AX) x ([SI]) iii) SHR SHR destination, count This instruction shifts each bit in the specified destination to the right and 0 is stored at MSB position. The LSB is shifted into the carry flag. The destination can be a byte or a word. It can be a register or in a memory location. The number of shifts is indicated by count. E.g. SHR CX, 1 MOV CL, 05H SHR AX, CL iv)cmp The CMP instruction compares two operands. It is generally used in conditional execution. This instruction basically subtracts one operand from the other for comparing whether the operands are equal or not. It does not disturb the destination or source operands. It is used along with the conditional jump instruction for decision making. Syntax CMP destination, source CMP compares two numeric data fields. The destination operand could be either in register or in memory. The source operand could be a constant (immediate) data, register or memory. Example CMP DX, 00 ; Compare the DX value with zero JE L7 ; If yes, then jump to label L7

.. L7:... CMP is often used for comparing whether a counter value has reached the number of times a loop needs to be run. Consider the following typical condition INC EDX CMP EDX, 10 ; Compares whether the counter has reached 10 JLE LP1 ; If it is less than or equal to 10, then jump to LP1 v)aam AAM : ASCII Adjust after Multiplication This instruction, after execution, converts the product available In AL into unpacked BCD format. Eg. MOV AL, 04 ; AL = 04 MOV BL,09 ; BL = 09 MUL BL ; AX = AL*BL ; AX=24H AAM ; AH = 03, AL=06 b)describe the result of executing the following sequence of instructions: MOV AL,01010101 (2) AND AL,00011111 (2) After execution AL=0001 0101 (2) =15H OR AL,11000000 (2) After execution AL=1101 0101 (2) =D5H XOR AL,00001111 (2) After execution AL=1101 1010 (2) =DAH NOT AL After execution AL=0010 0101 (2) =25H (3 Marks)

OR 2. a) Write an ALP to compute the factorial of a given 8 bit number using recursion. (5 Marks).MODEL SMALL.DATA NUMBER DW 04H.STACK.CODE MOV AX, @DATA MOV DS, AX MOV CX, NUMBER CALL FACT MOV AX, 4CH; EXIT TO OPERATING SYSTEM. INT 21H ;PROCEDURE FOR FACTORIAL PROGRAM ;ASSUME CX CONTAINS INPUT NUMBER ;ASSUME DX CONTAINS RESULT FACT PROC NEAR CMP CX, 01H JNE CONT MOV DX,01H RET CONT: PUSH CX ; FOR BACKUP DEC CX CALL FACT POP AX ; BACKUP OF CX I.E. N MUL DX ; N*(N-1)! MOV DX, AX RET FACT ENDP END ; RESULT INTO DX b)describe the following instructions with examples i) LOOP : LOOP Unconditionally This instruction executes the part of the program from the Label or address specified in the instruction up to the LOOP instruction CX number of times. At each iteration, CX is decremented automatically and JUMP IF NOT ZERO structure. Example: MOV CX, 0004H MOV BX, 7526H Label 1 MOV AX, CODE OR BX, AX LOOP Label 1 ii)wait The WAIT instruction monitors the hardware BUSY pin on 8086, and the TEST pin on the (3 Marks)

8086/8088. If WAIT instruction executes while the pin=1, nothing happens and the next instruction executes normally. If pin=0, when the WAIT instruction executes, the microprocessor waits for the pin to return to logic 1. This instruction is used to prevent the CPU from accessing memory that may be temporarily in use by the coprocessor. iii) RET: Return from the Procedure. At the end of the procedure, the RET instruction must be executed. When it is executed, the previously stored content of IP and CS along with Flags are retrieved into the CS, IP and Flag registers from the stack and execution of the main program continues further. PART 2 3. With syntax, explain conditional transfer and unconditional transfer instructions (8 Marks) The Branch Instructions are classified into two types i. Unconditional Branch Instructions. ii. Conditional Branch Instructions. Unconditional Branch Instructions: In Unconditional control transfer instructions, the execution control is transferred to the specified location independent of any status or condition. The CS and IP are unconditionally modified to the new CS and IP. a) CALL: Unconditional Call This instruction is used to call a Subroutine (Procedure) from a main program. Address of procedure may be specified directly or indirectly. There are two types of procedure depending upon whether it is available in the same segment or in another segment. i. Near CALL i.e., ±32K displacement. ii. Far CALL i.e., anywhere outside the segment. On execution this instruction stores the incremented IP & CS onto the stack and loads the CS & IP registers with segment and offset addresses of the procedure to be called. b) RET: Return from the Procedure. At the end of the procedure, the RET instruction must be executed. When it is executed, the previously stored content of IP and CS along with Flags are retrieved into the CS, IP and Flag registers from the stack and execution of the main program continues further. c) INT N: Interrupt Type N. In the interrupt structure of 8086, 256 interrupts are defined corresponding to the types from 00H to FFH. When INT N instruction is executed, the type byte N is multiplied by 4 and the contents of IP and CS of the interrupt service routine will be taken from memory block in 0000 segment. d) INTO: Interrupt on Overflow This instruction is executed, when the overflow flag OF is set. This is equivalent to a Type 4 Interrupt instruction. e) JMP: Unconditional Jump This instruction unconditionally transfers the control of execution to the specified address using an 8-bit or 16-bit displacement. No Flags are affected by this instruction. f) IRET: Return from ISR When it is executed, the values of IP, CS and Flags are retrieved from the stack to continue the execution of the main program.

Conditional Branch Instructions LOOP: LOOP Unconditionally This instruction executes the part of the program from the Label or address specified in the instruction up to the LOOP instruction CX number of times. At each iteration, CX is decremented automatically and JUMP IF NOT ZERO structure. Example: MOV CX, 0004H MOV BX, 7526H Label 1 MOV AX, CODE OR BX, AX LOOP Label 1 When this instruction is executed, execution control is transferred to the address specified relatively in the instruction, provided the condition implicit in the Opcode is satisfied. Otherwise execution continues sequentially. JZ/JE Label Transfer execution control to address Label, if ZF=1. JNZ/JNE Label Transfer execution control to address Label, if ZF=0 JS Label Transfer execution control to address Label, if SF=1. JNS Label Transfer execution control to address Label, if SF=0. JO Label Transfer execution control to address Label, if OF=1. JNO Label Transfer execution control to address Label, if OF=0. JNP Label Transfer execution control to address Label, if PF=0. JP Label Transfer execution control to address Label, if PF=1. JB Label Transfer execution control to address Label, if CF=1. JNB Label Transfer execution control to address Label, if CF=0. JCXZ Label Transfer execution control to address Label, if CX=0 Conditional LOOP Instructions. LOOPZ / LOOPE Label Loop through a sequence of instructions from label while ZF=1 and CX=0. LOOPNZ / LOOPENE Label Loop through a sequence of instructions from label while ZF=1 and CX=0.

OR 4. Explain the difference between macro and procedure with an example for each. (8 Marks) MACROS PROCEDURES Accessed during assembly when name given to macro is written as an instruction in the assembly program. Accessed by CALL and RET instructions during program execution. Machine code is generated for instructions each time a macro is called. Machine code for instructions is put only once in the memory. This due to repeated generation of machine code requires more memory. This as all machine code is defined only once so less memory is required. Parameters are passed as a part of the statement in which macro is called. Parameters can be passed in register memory location or stack. PART 3 5. Write an ALP using 8086 instructions to reverse a four digit number (8 Marks)

OR 6. Explain the various string manipulation instructions with examples. (8 Marks) a) MOVSB / MOVSW: Move String Byte or String Word Suppose a string of bytes stored in a set of consecutive memory locations is to be moved to another set of destination locations. The starting byte of source string is located in the memory location whose address may be computed using SI (Source Index) and DS (Data Segment) contents. The starting address of the destination locations where this string has to be relocated is given by DI (Destination Index) and ES (Extra Segment) contents. b) CMPSB/CMPSW : Compare String Byte or String Word The CMPS instruction can be used to compare two strings of byte or words. The length of the string must be stored in the register CX. If both the byte or word strings are equal, zero Flag is set. The REP instruction Prefix is used to repeat the operation till CX (counter) becomes zero or the condition specified by the REP Prefix is False. c) SCASB/SCASW : Scan String Byte or String Word This instruction scans a string of bytes or words for an operand byte or word specified in the register AL or AX. The String is pointed to by ES: DI register pair. The length of the string s stored in CX. The DF controls the mode for scanning of the string. Whenever a match to the specified operand is found in the string, execution stops and the zero Flag is set. If no match is found, the zero flag is reset. d) LODSB/LODSW : Load String Byte or String Word The LODS instruction loads the AL / AX register by the content of a string pointed to by DS: SI register pair. The SI is modified automatically depending upon DF, if it is a byte transfer (LODSB), the SI is modified by one and if it is a word transfer (LODSW), the SI is modified by two. No other Flags are affected by this instruction. e) STOSB/STOSW : Store String Byte or String Word The STOS instruction Stores the AL / AX register contents to a location in the string pointer by ES: DI register pair. The DI is modified accordingly; No Flags are affected by this instruction. The direction Flag controls the String instruction execution, the source index SI and Destination Index DI are modified after each iteration automatically. If DF=1, then the execution follows auto decrement mode, SI and DI are decremented automatically after each iteration. If DF=0, then the execution follows auto increment mode. In this mode, SI and DI are incremented automatically after each iteration.

PART 4 7. Using NAND gates and inverters, design decoding circuitry for an EPROM with the address range C0000H-C0FFFH. Solution: (8 Marks) The figure shows the decoder required to map the 64K memory interface to the address range C0000H to CFFFFH. Starting address Ending address A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Total number of memory locations=2 16 locations=64k

OR 8. With a neat diagram explain simple NAND gate address decoding logic to select 2K X 8 EPROM for 8086 processor (8 Marks)

PART 5 9. a)explain structure of 8086 interrupt vector table with a neat diagram (4 Marks) 00000H 1234H (4 Marks) 00002H 5678H 5678:1234H is IV number 0 00004H 3344H 00006H 5566H 5566:3344H is IV number 1 : : : 003FCH 6677H 003FEH 7788H 7788:6677H is IV number FF RAM locations 0 to 003FFH are used to store IVT. It contains 256 Interrupt vectors (IV) each of 4 bytes. Execution of INT n (n=0 to FF) 1. Push Flags on the stack 2. Reset IE flag (to ensure no further interrupts) 3. Reset T flag (so that ISS is not executed in single step) 4. PUSH CS 5. PUSH IP 6. IP loaded from word location n x 4 = say, W 7. CS loaded from next word location W+2

b)for the figure shown below,find the address range for a)y4 b)y2 and c)y7.verify the block size controlled by each Y

OR 10. Design a memory system for 8086 with one 64 KB RAM and one 64KB ROM at address 30000h and F0000h.Show the complete design along with memory mapping and draw the final diagram with address decoder. (8 Marks) * * * * * * *