20
SUBJECT :-MIC 22415 QUESTION BANK FOR CT2 1. Describe any six Addressing modes of 8086 with suitable example 1. Immediate addressing mode: An instruction in which 8-bit or 16-bit operand (data ) is specified in the instruction, then the addressing mode of such instruction is known as Immediate addressing mode. Example: MOV AX,67D3H 2. Register addressing mode An instruction in which an operand (data) is specified in general purpose registers, then the addressing mode is known as register addressing mode. Example: MOV AX,CX 3. Direct addressing mode An instruction in which 16 bit effective address of an operand is specified in the instruction, then the addressing mode of such instruction is known as direct addressing mode. Example: MOV CL,[2000H] 4. Register Indirect addressing mode An instruction in which address of an operand is specified in pointer register or in index register or in BX, then the addressing mode is known as register indirect addressing mode. Example: MOV AX, [BX] 5. Indexed addressing mode An instruction in which the offset address of an operand is stored in index registers (SI or DI) then the addressing mode

nvchavan.files.wordpress.com  · Web view2019-03-14 · in a specified byte or word to the . ... Load N2 no.in BX. ... POS DB ? NEG DB ? RESULT DB ? DATA ENDS. CODE SEGMENT

Embed Size (px)

Citation preview

SUBJECT :-MIC22415 QUESTION BANK FOR CT2

1. Describe any six Addressing modes of 8086 with suitable example

1. Immediate addressing mode:An instruction in which 8-bit or 16-bit operand (data ) is specified in the instruction, then the addressing mode of such instruction is known as Immediate addressing mode.Example: MOV AX,67D3H

2. Register addressing modeAn instruction in which an operand (data) is specified in general purpose registers, then the addressing mode is known as register addressing mode.Example: MOV AX,CX

3. Direct addressing modeAn instruction in which 16 bit effective address of an operand is specified in the instruction, then the addressing mode of such instruction is known as direct addressing mode.Example: MOV CL,[2000H]

4. Register Indirect addressing modeAn instruction in which address of an operand is specified in pointer register or in index register or in BX, then the addressing mode is known as register indirect addressing mode.Example: MOV AX, [BX]

5. Indexed addressing modeAn instruction in which the offset address of an operand is stored in index registers (SI or DI) then the addressing mode of such instruction is known as indexed addressing mode. DS is the default segment for SI and DI. For string instructions DS and ES are the default segments for SI and DI resp. this is a special case of register indirect addressing mode.Example:MOV AX,[SI]

6. Based Indexed addressing modean instruction in which the address of an operand is obtained by adding the contents of base register (BX or BP) to the content of an index register (SI or DI) The default segment register may be DS or ESExample:MOV AX, [BX][SI]

7. Register relative addressing modeAn instruction in which the address of the operand is obtained by adding the displacement (8-bit or 16 bit) with the contents of base registers or index registers (BX, BP, SI, DI). the default segment register is DS or ESExample: MOV AX, 50H[BX]

8. Relative Based Indexed addressing modeAn instruction in which the address of the operand is obtained by adding the displacement (8 bit or 16 bit) with the base registers (BX or BP) and index registers (SI or DI) to the default segment.

2. Select the instruction for each of the followingi)Rotate register BH left 4 times.ii)Multiply AL by 08H.iii)Signed division of BL and AL.iv)Move 4000H in BX register.v)Load offset 1000H in register BX.vi)Rotate BX to left 4 times through carry.

i) Rotate register BH left 4 times. Logical or bit manipulation Instructions This instruction rotates all bits in a specified byte or word to the left some number of

bit positions. MSB is placed as a new LSB and a new CF. E.g. ROL BH, 4 Rotate all bit in BH left by FOUR bit position.

ii) Multiply AL by 08H.MOV AL,08HMUL AL : Immediate Addressing mode.

iii) Signed division of BL and AL.MOV AL,N1MOV BL,N2IDIV BL : Divide a signed Byte in BL and Quotient in AL, remainder in BL

iv) Move 4000H in BX register.MOV BX, 4000H :- Immediate Addressing mode.BX is loaded with 16bit immediate data 4000H

v) Load offset 1000H in register BX.Direct Addressing Mode

BX will be loaded with the content of memory location whose offset is 1000H from base address

MOV AX,[1000H]

vi) Rotate BX to left 4 times through carry.

Logical or bit manipulation InstructionsThis instruction rotates all bits in a specified byte or word some number of bit positions to the left along with the carry flag. MSB is placed as a new carry and previous carry is place as new LSB.E.g. RCL BX, 4Rotate all bit in BX left by four bit position.

3. What is the use of REP in string related instruction?

a) What is the use of REP in string related instruction?1] REP: REP is a prefix which is written before one of the string instructions. It will cause during length counter CX to be decremented and the string instruction to be repeated until CX becomes 0.

Two more prefix.REPE/REPZ: Repeat if Equal /Repeat if Zero.It will cause string instructions to be repeated as long as the compared bytes or words are equal and CX≠0.REPNE/REPNZ: Repeat if not equal/Repeat if not zero.It repeats the strings instructions as long as compared bytes or words are not equal and CX≠0.Example: REP MOVSB

4. With examples, describe any four String instructions in 8086 assembly language.

1.MOVSB / MOVSW : Move String Byte or String Word 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.

2.CMPS : 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.

3. SCAN : 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.

4.LODS : 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.

5. What is stack? state its significance.

STACK: Simplified Stack Segment directiveThis simplified segment directive define the stack segment Default size of the stack is 1024 bytes.General form: STACK

. STACK 100

6. Draw the flowchart for Multiplication of two 16 bit numbers.

ALGORITHM1. Data initialization2. Load N1 no.in AX3. Load N2 no.in BX4. Multiply in BX5. Store result in AX and DX.6. END

7. Draw the Machine language instruction format for Register to Register transfer and state the function of each bit.

8. Write an ALP to perform 16-bit division of unsigned numbers.

16BIT DIVISION (IDIV)ASSUME CS:CODE, DS:DATADATA SEGMENTN1 DD 20000HN2 DW 100HQUOTIENT DW ?REMAINDER DW ?DATA ENDSCODE SEGMENTSTART: MOV AX,DATA MOV DS, AX MOV AX,[BX] DIV CX MOV [BX], AX MOV AX,[ BX +2] DIV CX MOV [BX +2], AX MOV AX, N1 MOV BX, N2 DIV BX MOV QUOTIENT, AX MOV REMAINDER, DX MOV AH, 4CH INT 21H CODE ENDS END START

9. Write an ALP to count number of ‘1’ in 16-bit number.

PROGRAM FIND ONES IN GIVEN NUMBERS

DATA SEGMENTNUM DW 50HONES DW ?RESULT DW ?DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART: MOV AX,DATA

MOV DS,AX MOV CX,02H MOV AX,NUM

UP: ROR AX,1 JC DOWN INC ONES

DOWN: LOOP UP MOV AX, RESULT

MOV AH,4CH INT 21H

CODE ENDSEND START

10.Write an ALP to count the number of positive and negative numbers in array.

DATA SEGMENTDATA SEGMENTNUM DB 10HPOS DB ?NEG DB ?

RESULT DB ?DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART: MOV AX,DATA

MOV DS,AX MOV AL,NUM ROL AL,1 JNC DOWN ROL AL,1 MOV POS,AL

DOWN: ROL AL,1 MOV NEG,AL

MOV AL, RESULTMOV AH,4CHINT 21H

CODE ENDSEND START

11.Write an ALP to find the smallest number in the Array.

DATA SEGMENTARRAY DB 78H,23H,12H,04H,08HSMALLEST DB ? RESULT DB ?DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART: MOV AX,DATA

MOV DS,AX MOV CX,05H MOV AL,[SI]

DEC CX UP: INC SI

CMP AL,[SI] JC NEXT

MOV AL,[SI] NEXT: LOOP UP

CMP AL,[SI]MOV SMALLEST,ALMOV AH,4CHINT 21H CODE ENDSEND START

12.State the advantages and disadvantages of using Procedure.

Advantages: 1) Modular programming 2) Reduced to work load and development time 3) Debugging of program easier 4) Reduction of line of code 5) Reusability of code 6) Library of procedure can be implemented.

Disadvantages of using Procedure Disadvantage using the procedures is the need for the stack Extra code is require to integrated procedure i.e. CALL and RET instruction. Run time required more between small procedure.

13.Define Procedure and write its syntax.

1) Procedure is a series of instructions is to be executed several times in a program, and called whenever required. 2) Program control is transferred to the procedure, when CALL instruction is executed at run time. 3) Memory required is less4) Stack is required at Procedure CALL. 5) Extra overhead time is required for linkage between the calling program and called procedure. 6) Parameters passed in registers, memory locations or stack. 7) RET is required at the end of the Procedure. 8) Procedure is called using: CALL <Procedure_name> Directives used: PROC, ENDP, FAR,NEAR

General Form : Procedure Name PROC ------------------------------------- Procedure Statements ------------------------------------- Procedure Name ENDP.

14.What do you mean by Recursive procedure?

Definition Recursive Procedures: A recursive procedure is a procedure which calls itself. Here, the program sets aside a few locations in stack for the storage of the parameters which are passed each time the computation is done and the value is returned. Each value returned is then obtained by popping back from the stack at every RET instruction when executed at the end of the procedure.

15.Give the difference between Inter segment and Intra segment CALL.

16.Compare Procedure and macro based on i) length of code ii) generation of object code iii) Calling method iv) Passing parameter.

Parameters Procedure macroLength of code Length of object code file is

lessLength of object code file become lengthy

Generation of object code

Object code is generated only once in memory

Object code is generated everytime the macro is called

Calling method CALL and RET instructions are used to call procedure and return from procedure

Macro can be called just by writing its name.

Passing parameter. Parameters can be passed in register memory location or stack.

Parameters are passed as a part of the statement in which macro is called.

17.Describe re-entrant and Recursive procedure with diagram.

Explain re-entrant procedure with diagram

Ans:

In some situation it may happen that Procedure 1 is called from main program Procrdure2 is called from procedure1And procedure1 is again called from procdure2. In this situation program execution flow re-enters in the procedure1. These types of procedures are called re-entrant procedures. A procedure is said to be re-entrant, if it can be interrupted, used and re-entered

without losing or writing over anything.,

18.What is the difference between Near and Far Procedure?

19.Define Macro.

20.Write an ALP for addition of two 8 bit BCD numbers using MACRO. ASSUME CS:CODE,DS:DATADATA SEGMENT NUM1 DB 04HNUM2 DB 06HBCD_SUM DB ?DATA ENDSCODE SEGMENT START:MOV AX,@DATA MOV DS, AX MOV AL, NUM1 MOV BL, NUM2 ADD AL,BL DAA MOV BCD_SUM, AL MOV AH,4CH INT 21H ENDM ENDS END START