29
MIC -22415 MSBTE SAMPLE PAPER SOLVED a) State the function of ALE and Ready pin of 8086. b) What is the role TEST instruction in Assembly language programming? c) List the major steps in developing an Assembly language program. 1. Defining the problem 2. Algorithm 3. Flowchart 4. Initialization checklist 5. Choosing instructions 6. Converting algorithms to assembly language program d) Define Procedure and write its syntax. 1

nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

  • Upload
    leanh

  • View
    230

  • Download
    2

Embed Size (px)

Citation preview

Page 1: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

MIC -22415 MSBTE SAMPLE PAPER SOLVED

a) State the function of ALE and Ready pin of 8086.

b) What is the role TEST instruction in Assembly language programming?

c) List the major steps in developing an Assembly language program.1. Defining the problem 2. Algorithm 3. Flowchart 4. Initialization checklist 5. Choosing instructions 6. Converting algorithms to assembly language program

d) 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.

1

Page 2: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

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> 9) Directives used: PROC, ENDP, FAR,NEAR

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

e) 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

f) 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

2

Page 3: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

g) 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

Q-2 SOLVE -4MARKS EACH

a) Give the difference between Inter segment and Intra segment CALL.

3

Page 4: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

b) What is pipelining? How it improves the processing speed?

Description: Process of fetching the next instruction while the current instruction is executing is called pipelining which will reduce the execution time. The technique used to enable an instruction to complete with each clock cycle. Normally, on a non – pipelined processor, nine clock cycles are required for fetch, decode and execute cycles for the three instructions as shown in Fig (a). This takes longer time when compared to pipelined processor. In this ,the fetch, decode and execute operations are performed in parallel, so only five clock cycles are required to execute the same three instructions as shown Fig(b). In 8086, pipelining is implemented by providing 6 byte queue where as long as 6 one byte instructions can be stored well in advance and then one by one instruction goes for decoding and executions. So, while executing first instruction in a queue, processor decodes second instruction and fetches 3rd instruction from the memory In this way, 8086 perform fetch, decode and execute operation in parallel i.e. in single clock cycle as shown in above fig (b)

4

Page 5: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

c) State the Assembler Directives used in 8086 programming and describe the function of any two.

(i) DB (ii) DW (iii) DD (iv) DQ (v) DUP (vi)EQU

DB (Define Byte) • This is used to define a byte type variable. • The range of values : 0 – 255 for unsigned numbers -128 to 127 for signed numbers • This can be used to define a single byte or multiple bytes DW (Define Word) • This is used to define a word (16-bit) type variable. • The range of values : 0 – 65535 for unsigned numbers -32768 to 32767 for signed numbers • This can be used to define a single word or multiple words DD (Define Double Word) • This is used to define a double word (32-bit) type variable. • This can be used to define a single double word or multiple double word DQ ( Define Quad Word) This is used to define a quad word (64-bit) type variable. •This directive is used to tell the assembler to declare a variable 4 words in length or to reserve 4 words of storage.

INCLUDE –

• This INCLUDE directive is used to insert a block of source code from the named file into the current source module. • The directive INCLUDE informs the assembler to include the statement defined in the include file. The name of the include file follows the statement INCLUDE.

DUP: Duplicate memory location:- • This directive can be used to generate multiple bytes or words with known as well as un-initialized values.

5

Page 6: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

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

Write the function

Q.3) Attempt any THREE of the following. 12 Marks

6

Page 7: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

a) Describe Memory segmentation in 8086 and list its advantages.

Memory Segmentation:

The memory in an 8086 microprocessor is organized as a segmented memory. The physical memory is divided into 4 segments namely,-Data segment, Code Segment, Stack Segment and Extra Segment.Description:Data segment is used to hold data, Code segment for the executable program, Extrasegment also holds data specifically in strings and stack segment is used to storestack data.Each segment is 64Kbytes & addressed by one segment register.

The 16 bit segment register holds the starting address of the segment.

The offset address to this segment address is specified as a 16-bit displacement (offset) between0000 to FFFFH.Since the memory size of 8086 is 1Mbytes, total 16 segments are possible with eachhaving 64Kbytes.

7

Page 8: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

b) Write an ALP to perform 32 bit by 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

8

Page 9: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

c) 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

d) Compare Procedure and macro based on

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.

or

9

Page 10: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

Q.4) Attempt any THREE of the following. 12 Marksa) Draw and explain the flag register of 8086.

6 ARE STATUS FLAG AND 3 ARE CONTROL FLAGSCarry flag: This flag is set when there is a carry out of MSB in case of addition or a borrow in case of subtraction. Parity flag: This flag is set, if the lower byte of the result contains even numbers of 1s Auxiliary carry flag : this is set if there is a carry from the lowest nibble, i.e. bit three during addition or borrow for the lowest nibble i.e. bit three during subtraction. Zero flag: This flag is set if the result of the computation or comparison performed by previous instruction is zero.

10

Page 11: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

Sign flag: this flag is set when the result of any computation is negative. For signed computations the sign flag equals the MSB of the result. Trap flag if this flag is set the processor enters the single step execution mode. Interrupt flag: If this flag is set the maskable interrupts are recognized by the cpu, otherwise they are ignored. Direction flag: This flag is used by string manipulation instructions. If this flag bit is „0‟ the string is processed beginning from the lowest address to the highest address, otherwise the string is processed from the highest address towards lowest address. Overflow flag: This flag is set if an overflow occurs.

b) 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

Page 12: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

c) Write an ALP to find the smallest number in the Array.

FIND SMALLEST NO OF ARRAYS

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

Page 13: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

d) 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

e) Describe re-entrant and Recursive procedure with diagram.

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.

Definition 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. To be a re-entrant, 1) Procedure must first push all the flags and registers used in the procedure. 2) It should also use only registers or stack to pass parameters.

13

Page 14: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

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.,

Explain Recursive procedure with diagram

14

Page 15: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

Q.5) Attempt any TWO of the following. 12 Marksa) Define logical and effective address. Describe physical address generation process in 8086.Calculate physical address by taking suitable DS, CS and IP.

Define logical :The logical address is a virtual address and can be viewed by the userlogical address is generated by CPU during a program execution 

Effective address:An addressing mode specifies how to calculate the effective memory address of an operand by using information held in registers and/or constants contained within a machine instruction.

15

Page 16: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

List the steps in physical address generation in 8086 microprocessor. Generation of 20 bit physical address in 8086 :- 1. Segment registers carry 16 bit data, which is also known as base address. 2. BIU appends four 0 bits to LSB of the base address. This address becomes 20-bit address. 3. Any base/pointer or index register carries 16 bit offset. 4. Offset address is added into 20-bit base address which finally forms 20 bit physical address of memory location.

Calculate physical address in the following cases: (2M each)

i) CS: 1200H, IP:DE00H

16

Page 17: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

b) Describe how an assembly language program is developed and debugged using system tools such as editors, assemblers, linkers and debuggers.

List the program development steps for assembly language programming. 1. Defining the problem 2. Algorithm 3. Flowchart 4. Initialization checklist 5. Choosing instructions 6. Converting algorithms to assembly language program

Describe Assembler, Linker and Debugger.Linker: 1. It is a programming tool used to convert Object code into executable program called .EXE module.2. It combines, if requested, more than one separated assembled modules into one executable module such as two or more assembly programs or an assembly language with C program.

Assembler:- 1. Assembler is a program that translates assembly language program to the correct binary code. 2. It also generates the file called as object file with extension .obj. 3. It also displays syntax errors in the program, if any. 4.It can be also be used to produce list(.lst) and .crf files Debugger: - 1. Debugger is a program that allows the execution of program in single step mode under the control of the user. 2. The errors in program can be located and corrected using a debugger. 3. Debugger generates .exe file.

17

Page 18: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

d) Describe any six Addressing modes of 8086 with suitable example.ANS: 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 isa 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 mode

18

Page 19: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

An 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.

19

Page 20: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

Q.6) Attempt any TWO of the following. 12 Marksa) 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.

20

Page 21: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

5.STOS : Store String Byte or String Word The STOS instruction Stores the AL / AX register in the string pointer by

ES : DI register pair. The direction Flag DF 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.

b) Select the instruction for each of the following

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.MUL 08H : Immediate Addressing mode.

iii) Signed division of BL and AL.IDIV 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.

21

Page 22: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

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.

c) Write an ALP for concatenation of two strings. Draw flowchart and assume suitable data.Data segmentstr db ‘HELLO-$’dsc db ‘AND-WELCOME$’data endsassume cs:code,ds:datacode segmentstart: mov ax, data

movds, ax

mov si, offset str mov di,offset dscLOOP: mov al,[si] cmp al, '$' Je secloop inc si jmp LOOP secloop:mov al,[di] cmp al,'$' je exit mov [si],al inc di inc si jmp secloop exit:mov [si],'$' mov dx,offset STR mov ah,09h int 21h mov ah,4ch

int 21hcode endsend start

22

Page 23: nvchavan.files.wordpress.com  · Web viewMIC -22415 MSBTE SAMPLE PAPER SOLVED . State the function of ALE and Ready pin of 8086. What is the role TEST instruction in Assembly language

23