- CS401 – Midterm Solved Past Papers
- Computer Architecture and Assembly Language Programming
- Q1. Describe Push and Pop with the help of an example.
- Q2. Explain all characteristics of SCAS instruction.
- Q3. Describe Local Variable?
- Q4. What is difference between REPE and REPNE?
- Q5: Affected flag of AND operation.
- Q6: Relation between RET and CALL is dependent or independent.
- Q7: What is the difference between LES and LDS instruction?
- Q8.Write down the procedure to clear the selective bit. (Marks: 2)
- Q9. Why REP prefix is generally not used with LODS instruction?
- Q10. Explain divide overflow error.
- Q11. For what purpose “INT4” is reserved.
- Q12. Double working of Exchange instruction with help of an example.
- Q13. Describe push & pop with help of example
- Q14. How value of Ip Register is saved & updated when call. Instruction executed.
- Q15. How many block processing instructions in 8088, just name the number of processing instructions?
- Q16. What are the instruction use by assembly language for permanent diversion and temporarily diversion?
- Q17. How much string instructions are in assembly language? Write down all instructions.
- Q18. What is the purpose of following string instructions?
- Q19. Describe the working of the CALL instruction with the reference of Stack.
- Q20. Write all steps of algorithm for printing number 352.
- Q21. Explain the complete operation of Interrupt when it is generated.
- Q22. IF DF=0 what its represent and IF DF=1 what its represent?
- Q23. Explain how extended shifting is performed.
- Q24. Why is it necessary to provide the segment and offset address in case of FAR jump ?
- Q25. What’s your understanding about Incrementing and Decrementing Stack?
- Q26. What is the Difference between CALL and RET
- Q27. Explain the process of ADC?
- Q28. Define implied operand?
CS401 – Midterm Solved Past Papers
Computer Architecture and Assembly Language Programming
Q1. 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.
Q2. 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.
Q3. 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. The most convenient place to store these variables is the stack. We need some special manipulation of the stack for this task. We need to produce a gap in the stack for our variables.
Q4. 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.
Q5: 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.
Q6: 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.
Q7: 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.
Q8.Write down the procedure to clear the selective bit. (Marks: 2)
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.
Q9. Why REP prefix is generally not used with LODS instruction?
Answer:- LODS is generally used in a loop and not with the REP prefix since the value previously loaded in the register is overwritten if the instruction is repeated and only the last value of the block remains in the register.
Q10. 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.
Q11. 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).
Q12. Double working of Exchange instruction with help of an example.
Answer:- xchg ax, [bx+si+2] ; exchange ax with second number
Q13. Describe push & pop with help of example
PUSH decrements SP (the stack pointer) by two and then transfers a word from the source operand to the top of stack now pointed to by SP. PUSH often is used to place parameters on the stack before calling a procedure; more generally, it is the basic means of storing temporary data on the stack. Consider the example of test tube.
POP transfers the word at the current top of stack (pointed to by SP) to the destination operand and then increments SP by two to point to the new top of stack. POP can be used to move temporary variables from the stack to registers or memory. Observe that the operand of PUSH is called a source operand since the data is moving to the stack from the operand, while the operand of POP is called destination since data is moving from the stack to the operand.
Q14. How value of Ip Register is saved & updated when call. Instruction executed.
Answer:- This is the special register containing the address of the next instruction to be executed. No mathematics or memory access can be done through this register. It is out of our direct control and is automatically used. Playing with it is dangerous and needs special care. Program control instructions change the IP register.
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
Answer:- The instructions for permanent diversion in 8088 are the jump instructions, while the instruction for temporary diversion is the CALL instruction.
Q17. How much string instructions are in assembly language? Write down all instructions.
STOS – Clearing the Screen
LODS – String Printing
SCAS -String Length
LES and LDS
MOVS -Screen Scrolling
CMPS – String Comparison
Q18. What is the purpose of following string instructions?
a. STOS b. CMPS
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.
Q19. 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.
Q20. Write all steps of algorithm for printing number 352.
Answer:- The steps of our algorithm are outlined below.
• Divide the number by base (10 in case of decimal)
• The remainder is its right most digit
• Convert the digit to its ASCII representation (Add 0x30 to the remainder in case of decimal)
• Save this digit on stack
• If the quotient is non-zero repeat the whole process to get the next digit, otherwise stop
• Pop digits one by one and print on screen left to right
Q21. Explain the complete operation of Interrupt when it is generated.
Answer:- Interrupt is the result of an INT instruction (software interrupt) or it is generated by an external hardware which passes the interrupt number by a different mechanism. The currently executing instruction is completed, the current value of FLAGS is pushed on the stack, then the current code segment is pushed, then the offset of the next instruction is pushed. After this it automatically clears the trap flag and the interrupt flag to disallow further interrupts until the current routine finishes. After this it loads the word at nx4 in IP and the word at nx4+2 in CS if interrupt n was generated. As soon as these values are loaded in CS and IP execution goes to the start of the interrupt handler. When the handler finishes its work it uses the IRET instruction to return to the caller. IRET pops IP, then CS, and then FLAGS. The original value of IF and TF is restored which re-enables further interrupts
Q22. 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.
Q23. Explain how extended shifting is performed.
Answer:- Using our basic shifting and rotation instructions we can effectively shift a 32bit number in memory word by word. We cannot shift the whole number at once since our architecture is limited to word operations. The algorithm we use consists of just two instructions and we name it extended shifting.
num1: dd 40000
shl word [num1], 1
rcl word [num1+2], 1
The DD directive reserves a 32bit space in memory, however the value we placed there will fit in 16bits. So we can safely shift the number left 16 times. The least significant word is accessible at num1 and the most significant word is accessible at num1+2. The two instructions are carefully crafted such that the first one shifts the lower word towards the left and the most significant bit of that word is dropped in carry. With the next instruction we push that dropped bit into the least significant bit of the next word effectively joining the two 16bit words. The final carry after the second instruction will be the most significant bit of the higher word, which for this number will always be zero.
Q24. 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.
Q25. 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.
Q26. 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.
Q27. 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.
Q28. 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.