0% found this document useful (0 votes)
17 views11 pages

Mic CT-2

The document contains sample questions and answers for a MIC CT-2 exam. It includes definitions of terms like macro and procedure, examples of assembly language programs to find the largest number in an array, reverse a string, and sort numbers, and explanations of instructions like ADC, TEST, CMP and ROL.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
17 views11 pages

Mic CT-2

The document contains sample questions and answers for a MIC CT-2 exam. It includes definitions of terms like macro and procedure, examples of assembly language programs to find the largest number in an array, reverse a string, and sort numbers, and explanations of instructions like ADC, TEST, CMP and ROL.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 11

MIC CT-2 Question Bank Answers

2 marks questions

1.Define micro.give syntax and example


Ans:
Macro: Small sequence of the codes of the same pattern are repeated frequently at different places which
perform the same operation on the different data of same data type, such repeated code can be written
separately called as Macro.
Syntax: Macro_nameMACRO[arg1,arg2,…..argN)
…..
End

2.Define procedure.give syntax and example


Ans:
Procedure: A procedure is group of instructions that usually performs one task. It is a reusable section of a
software program which is stored in memory once but can be used as often as necessary. A procedure can
be of two types. 1)Near Procedure 2) Far Procedure

3.write and ALE to find out largest number the given array
Ans:

DATA SEGMENT
ARRAY DB 10H,24H,02H,05H,17H

LARGEST DB 00H

DATA ENDS
CODE SEGMENT

ASSUME CS:CODE,DS:DATA

START: MOV DX,DATA

MOV DS,DX

MOV CX,04H

MOV SI ,OFFSET

ARRAY MOV AL,[SI]

UP: INC SI

CMP AL,[SI]

JNC NEXT

MOV AL,[SI]

NEXT: DEC CX

JNZ UP

MOV LARGEST,AL

MOV AX,4C00H

INT 21H

CODE ENDS

END START

4.What is the use of REP instruction & also explain string related instruction?
Ans:
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 bytesor 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 notequalAnd CX≠0.
Example: REP MOVSB
5.Write any two difference between NEAR and FAR procedure

6. Difference between ROL & ROR


7.explain directive in MACRO and PROCEDURE

8.explan following instruction ADC ,TEST, CMP,ROL

1. ADC (Add with Carry)


• Function: Adds a value and the Carry flag (C) to a register.
• Operation: Register = Register + Value + Carry
• Carry flag:
o Set to 1 if the addition results in a carry-over from the most significant bit (MSB).
o Cleared to 0 otherwise.
• Use cases:
o Perform multi-byte additions efficiently by chaining ADC instructions.
o Add values exceeding the register's capacity (overflow handling).
2. TEST
• Function: Performs a bitwise AND operation between a register and another value (usually zero).
• Operation: Flags = Register AND Value (usually Value = 0)
• Flags affected:
o Zero flag (Z): Set to 1 if the result is zero (all bits are 0).
o Parity flag (P): Set based on the number of 1 bits in the result (even or odd).
o Other flags (Carry, Auxiliary Carry, etc.) are typically not affected.
• Use cases:
o Check if a register contains zero without modifying its value.
o Set flags for conditional branching based on specific bit patterns.
3. CMP (Compare)
• Function: Subtracts a value from a register, but the result is not stored.
• Operation: Flags = Register - Value
• Flags affected:
o Zero flag (Z): Set to 1 if the result is zero (register equals value).
o Carry flag (C): Set to 1 if the subtraction would result in a borrow from the MSB (register is
less than value).
o Sign flag (N): Set to the sign of the result (1 for negative, 0 for positive or zero).
o Overflow flag (V): Set if the subtraction would overflow the register's capacity (incorrect
result due to signedness).
• Use cases:
o Compare two values for conditional branching (e.g., if greater than, less than, equal).
o Perform signed or unsigned comparisons without modifying the register.
4. ROL (Rotate Left)
• Function: Rotates the bits in a register one position to the left.
• Operation:
o The leftmost bit (bit 7) is shifted out and becomes the new Carry flag (C).
o All other bits are shifted one position to the left.
• Carry flag:
o Set to the value of the original leftmost bit (bit 7) before the rotation.
• Use cases:
o Implement multiplication or division by powers of 2 efficiently.
o Serialization/deserialization of bit streams with left-to-right order.
o Perform bit-level manipulations depending on the specific instruction set.
4 marks questions
1.write an ALP to find sum of series. Assume series of 10 numbers
DATA SEGMENT
NUM1 DB 10H, 02H, 30H, 04H, 05H, 06H, 07H, 08H, 09H, 10H
RESULT DB 10 DUP (0)
CARRY DB 0H
DATA ENDS
CODE SEGMENT
START:
ASSUME CS: CODE, DS:DATA
MOV DX, DATA
MOV DS, DX
MOV CL, 10H
CALL SERIES_ADD
MOV AX, 4C00H
INT 21H
SERIES_ADD PROC
MOV SI, OFFSET NUM1
UP:
MOV AL, [SI]
ADD RESULT, AL
JNC NEXT
INC CARRY
NEXT:
INC SI
LOOP UP
RET
SERIES_ADD ENDP
CODE ENDS
END START
2.write ALP using to perform block transfer operation of 10 numbers
DATA SEGMENT

BLOCK1 DW 1001H,4003H,6005H,2307H,4569H, 6123H, 1865H, 2345H,4000H,8888H

DATA ENDS
EXTRA SEGMENT

BLOCK2 DW?

EXTRA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA, ES: EXTRA

START: MOV AX, DATA

MOV DS, AX

MOV AX, EXTRA

MOV ES, AX

MOV CX,000AH

LEA SI, BLOCK1

LEA DI, ES: BLOCK2


CLD

REPNZ MOVSW

MOV AX,4C00H

INT 21H

CODE ENDS

END START

3.write an ALP using procedure to solve the equation such as z= (a + b) * (c +d)


Ans:

SUM PROC NEAR

ADD AL, BL

RET SUM

ENDP

DATA SEGMENT

NUM1 DB 10H

NUM2 DB 20H

NUM3 DB 30H

NUM4 DB 40H
RESULT DB?

DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS:DATA

START:MOV AX, DATA

MOV DS, AX

MOV AL, NUM1

MOV BL, NUM2

CALL SUM

MOV CL, AL

MOV AL, NUM3

MOV BL, NUM4

CALL SUM

MUL CL

MOV RESULT, AX

MOV AH,4CH

INT 21H

CODE ENDS

END START

4.describe re-entrant and re-cursive procedure with suitable diagram


Ans: In some situation it may happen that Procedure 1is called from main program Procrdure2 is called
from procedure1And procrdure1 is again called from procdure2. In this situation program execution flow
reenters in the procedure1. These types of procedures are called re-entrant procedures. The RET
instruction at the end of procrdure1 returns to procedure2. The RET instruction at the end of procedure2
will return the execution to procedure1.Procedure1 will again be executed from where it had stopped at
the time of calling procrdure2 and the RET instruction at the end of this will return the program execution
to main program. The flow of program execution for re-entrant procedure is as shown in FIG.
Re-entrant Procedure: A re-entrant procedure is one in which a single copy of the program code can be
shared by multiple users during the same period of time. Re-entrance has two key aspects: The program
code cannot modify itself and the local data for each user must be stored separately.
Recursive procedures: An active procedure that is invoked from within itself or from within another active
procedure is a recursive procedure. Such an invocation is called recursion. A procedure that is invoked
recursively must have the RECURSIVE attribute specified in the PROCEDURE statement.

5.write an institution to perform following operations


1) multiply BL by 88H
2) signed division of Al by BL
3) Move 4000H to DS register
4) Rotate content of AX
register to left 4 times

6.Draw flowchart and write ALP to reverse the word in string


Program:

DATA SEGMENT

STRB DB 'GOOD MORNING$'

REV DB 0FH DUP(?)

DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS:DATA

START: MOV DX, DATA

MOV DS, DX

LEA SI, STRB

MOV CL,0FH

LEA DI, REV

ADD DI,0FH

UP:MOV AL, [SI]

MOV [DI], AL

INC SI

DEC DI

LOOP UP

INT 21H

CODE ENDS

END START

7. Write an ALP the numbers in ascending order


Ans:

DATA SEGMENT

ARRAY DB 15h,05h,08h,78h,56h, 60h, 54h, 35h, 24h, 67h

DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS:DATA

START:MOV DX, DATA

MOV DS, DX

MOV BL,0AH

step1: MOV SI, OFFSET ARRAY


MOV CL,09H

step: MOV AL, [SI]

CMP AL, [SI+1]

JC Down

XCHG AL, [SI+1]

XCHG AL, [SI]

Down: ADD SI,1

LOOP step

DEC BL

JNZ step1

CODE ENDS

END START

8 Compare PROCEDURE and MACRO

S.
MACRO PROCEDURE
No.
Macro definition contains a set of Procedure contains a set of instructions
01. instruction to support modular which can be called repetitively which can
programming. perform a specific task.
It is used for small set of instructions mostly It is used for large set of instructions mostly
02.
less than ten instructions. more than ten instructions.
In case of macro memory requirement is In case of procedure memory requirement
03.
high. is less.
CALL and RET instruction/statements are CALL and RET instruction/statements are
04.
not required in macro. required in procedure.

Assembler directive MACRO is used to Assembler directive PROC is used to define


05. define macro and assembler directive procedure and assembler directive ENDP is
ENDM is used to indicate the body is over. used to indicate the body is over.

Execution time of macro is less as it Execution time of procedures is high as it


06.
executes faster than procedure. executes slower than macro.
Here machine code is created multiple Here machine code is created only once, it
07. times as each time machine code is is generated only once when the procedure
generated when macro is called. is defined.
In a macro parameter is passed as part of In a procedure, parameters are passed in
08.
statement that calls macro. registers and memory locations of stack.
Overhead time takes place during calling
Overhead time does not take place as there
09. procedure and returning control to calling
is no calling and returning.
program.

You might also like