Cs401 Midterm Subjective
Cs401 Midterm Subjective
Cs401 Midterm Subjective
Cs401
Assembly Language
Most Repeated Subjective Midterm
https://youtube.com/channel/UC_Ar-KkTPqjaljUX2LimmOQ
Question No 1
Why is it necessary to provide the segment and offset address in case of FAR jump ?
Answer:-
Far jump must be used a two byte segment and a two byte offset are given to it Because It
loads CS with the segment part and IP with the offset part.
Question No 2
What’s your understanding about Incrementing and Decrementing Stack?
Answer:-
A decrementing stack moves from higher addresses to lower addresses as elements are added
in it while an incrementing stack moves from lower addresses to higher addresses as elements
are added.
Question No 3
What is difference between SHR and SAR instructions?
Answer:-
The shift logical right operation inserts a zero from the left and moves every bit one position to
the right and copies the rightmost bit in the carry flag.
Question No 4
Define implied operand?
Answer:-
An implied operand means that it is always in a particular register say the accumulator, and it
need not be mentioned in the instruction.
Question No 5
Question No 6
Define short jump
Answer:-
If the offset is stored in a single byte as in 75F2 with the opcode 75 and operand F2, the jump is
called a short jump.
Question No 7
Explain the function of rotate right (ROR) instruction
Answer:-
In the rotate right operation every bit moves one position to the right and the bit dropped from
the right is inserted at the left. This bit is also copied into the carry flay.
Question No 8
How many parameters a subroutine can receive through stack.
Answer:-
Question No 9
Double working of Exchange instruction with help of an example.
Answer:-
Xchg ax, [bx+si+2] ; exchange ax with second number
Question No 10
Relation between RET and CALL is dependent or independent.
Answer:-
Technically they are independent in their operation but both the instructions are commonly
used as a pair. The RET works regardless of the CALL and the CALL works regardless of the RET.
Question No 11
What is the difference between LES and LDS instruction?
Answer:-
LES loads ES while LDS loads DS. These instructions have two parameters, one is the general
purpose register to be loaded and the other is the memory location from which to load these
registers.
Question No 12
Write down the procedure to clear the selective bit.
Answer:-
The source operand is loaded with a mask containing one at positions which are retain their old
value and zero at positions which are to be zeroed. The effect of applying this operation on the
destination with mask in the source is to clear the desired bits. This operation is called masking.
Question No 13
Question No 14
What is difference between REPE and REPNE?
Answer:-
REPE or REPZ repeat the following string instruction while the zero flag is set and REPNE or
REPNZ repeat the following instruction while the zero flag is not set.
Question No 15
Describe Push and Pop with the help of an example.
Answer:-
The operations of placing items on the stack and removing them from there are called push and
pop. Memory is like a shelf numbered as zero at the top and the maximum at the bottom. If a
decrementing stack starts at shelf 5, the first item is placed in shelf 5; the next item is placed in
shelf 4, the next in shelf 3 and so on
Question No 16
How many block processing instructions in 8088, just name the number of processing
instructions?
Answer:-
There are just 5 block processing instructions in 8088. The five instructions are STOS, LODS,
CMPS, SCAS, and MOVS called store string, load string, compare string, scan string, and move
string respectively
Question No 17
What are the instruction use by assembly language for permanent diversion and temporarily
diversion?
Answer:-
The instructions for permanent diversion in 8088 are the jump instructions, while the
instruction for temporary diversion is the CALL instruction.
Question No 18
How much string instructions are in assembly language? Write down all instructions.
Answer:-
STOS – Clearing the Screen
LODS – String Printing
SCAS -String Length
Question No 19
For what purpose DS and ES registers are generally used in the context of video memory.
Answer:-
Both DS and ES can be used to access the video memory. However we commonly keep DS for
accessing our data, and load ES with the segment of video memory.
Question No 20
What colors are repeated by 0th, 1st and 2nd bits (from least significant side) in Attribute
Byte?
Answer:-
Blue , green , Red
Question No 21
Describe the working of the CALL instruction with the reference of Stack.
Answer:-
During the CALL operation, the current value of the instruction pointer is automatically saved
on the stack, and the destination of CALL is loaded in the instruction pointer. Execution
therefore resumes from the destination of CALL.
Question No 22
Explain the use of TEST instruction.
Answer:-
The test instruction is used for bit testing. BX holds the mask and in every next iteration it is
shifting left, as our concerned bit is now the next bit.
Question No 1
What is the Difference between CALL and RET
Answer:-
The CALL instruction allows temporary diversion and therefore reusability of code. The word
return holds in its meaning that we are to return from where we came and need no explicit
destination. Therefore RET takes no arguments and transfers control back to the instruction
following the CALL that took us in this subroutine.
Question No 2
Affected flag of AND operation
Answer:-
AND can be used to check whether particular bits of a number are set or not. Previously we
used shifting and JC to test bits one by one. Now we introduce another way to test bits, which is
more powerful in the sense that any bit can be tested anytime and not necessarily in order.
AND can be applied on a destination with a 1-bit in the desired position and a source, which is
to be checked. If the destination is zero as a result, which can be checked with a JZ instruction,
the bit at the desired position in the source was clear.
Question No 3
Describe Local Variable?
Answer:-
Another important role of the stack is in the creation of local variables that are only needed
while the subroutine is in execution and not afterwards. They should not take permanent space
like global variables. Local variables should be created when the subroutine is called and
discarded afterwards. So that the spaced used by them can be reused for the local variables of
another subroutine. They only have meaning inside the subroutine and no meaning outside it.
Question No 4
Explain all characteristics of SCAS instruction.
Answer:-
SCAS compares a source byte or word in register AL or AX with the destination string element
addressed by ES:DI and updates the flags. DI is updated to point to the next location. SCAS is
often used to locate equality or in-equality in a string through the use of an appropriate prefix.
SCAS is a bit different from the other instructions. This is more like the CMP instruction in that it
does subtraction of its operands. The prefixes REPE (repeat while equal) and REPNE (repeat
while not equal) are used with this instruction. The instruction is used to locate a byte in AL in
the block of memory. When the first equality or inequality is encountered; both have uses.
Question No 5
Explain divide overflow error.
Answer:-
If a large number is divided by a very small number it is possible that the quotient is larger than
the space provided for it in the implied destination. In this case an interrupt is automatically
generated and the program is usually terminated as a result. This is called a divide overflow
error.
Question No 6
For what purpose “INT4” is reserved.
Answer:-
The overflow flag is set if the sign bit unexpectedly changes as a result of a mathematical or
logical instruction. However the overflow flag signals a real overflow only if the numbers in
question are treated as signed numbers. So this interrupt is not automatically generated but as
a result of a special instruction INTO (interrupt on overflow) if the overflow flag is set.
Otherwise the INTO instruction behaves like a NOP (no operation).
Question No 7
What is the purpose of following string instructions?
STOS
CMPS
Answer:-
STOS:-
STOS transfers a byte or word from register AL or AX to the string element addressed by ES:DI
and updates DI to point to the next location. STOS is often used to clear a block of memory or
fill it with a constant.
CMPS:-
CMPS subtracts the source location DS:SI from the destination location ES:DI. Source and
Destination are unaffected. SI and DI are updated accordingly. CMPS compares two blocks of
memory for equality or inequality of the block. It subtracts byte by byte or word by word.
Question No 8
How SCAS instructions can be used to detect Null at the end of a string?
Answer:-
SCAS instruction can be used to search for a 0 in a null terminated string to calculate the length
of the string. In this form REPNE will be used to repeat while the null is not there.
Question No 9
Question No 10
Write all steps of algorithm for printing number 352.
Answer:-
Question No 11
used with a REPE or a REPNE prefix is repeats as long as the blocks are same or as long as they
are different.
Question No 12
Explain MUL instruction in both cases (i) if the source operand is byte (ii) if the source
operand is a word?
Answer:-
MUL (multiply) performs an unsigned multiplication of the source operand and the
accumulator. If the source operand is a byte, then it is multiplied by register AL and the double-
length result is returned in AH and AL. If the source operand is a word, then it is multiplied by
register AX, and the double-length result is returned in registers DX and AX.
Question No 13
IF DF=0 what its represent and IF DF=1 what its represent?
Answer:-
The direction of movement is controlled with the Direction Flag (DF) in the flags register. If this
flag is cleared DF=0, the direction is from lower addresses towards higher addresses and if this
flag is set DF=1, the direction is from higher addresses to lower addresses. If DF is cleared, DF =
0 this is called the auto increment mode of string instruction, and if DF is set, DF=1, this is called
the auto decrement mode. There are two instructions to set and clear the direction flag.
Question No 14
Explain the process of ADC?
Answer:-
The ADC instruction is specifically placed for extending the capability of ADD. Numbers of any
size can be added using a proper combination of ADD and ADC. All basic building blocks are
provided for the assembly language programmer, and the programmer can extend its
capabilities as much as needed by using these fine instructions in appropriate combinations.
Further clarifying the operation of ADC, consider an instruction “ADC AX, BX.” Normal addition
would have just added BX to AX, however ADC first adds the carry flag to AX and then adds BX
to AX. Therefore the last carry is also included in the result.
Question No 15
Push di
Mov ax, 0xb800
Moves, ax ; point es to video base
Xor di, di ; point di to top left column
Question No 16
Explain all characteristics of SCAS instruction.
Answer:-
SCAS compares a source byte or word in register AL or AX with the destination string element
addressed by ES:DI and updates the flags. DI is updated to point to the next location. SCAS is
often used to locate equality or in-equality in a string through the use of an appropriate prefix.
Question No 17
Explain LES and LDS
Answer
The string instructions need source and destination in the form of a segment offset pair. LES
and LDS load a segment register and a general purpose register from two consecutive memory
locations. LES loads ES while LDS loads DS. Both instructions has two parameters, one is the
general purpose register to be loaded and the other is the memory location from which to load
these registers. The major application of these instructions is when a subroutine receives a
segment offset pair as an argument and the pair is to be loaded in a segment and an offset
register.
Channel Link
https://youtube.com/channel/UC_Ar-KkTPqjaljUX2LimmOQ
Or Search on Youtube Learning With A&I
Subscribe Channel And Get More Post
For More Help Contact 03131778082
Please Subscribe Channel Learning With A&I Page 14