CS401 Midterm Subjective
- Type
- Midterm past paper
- Course
- CS401 Computer Architecture and Assembly Language Programming
- Size
- PDF 265 KB
- Updated
- 23 Oct 2026
You get 3 free files a day on the website. Add the Chrome extensionSign in with the extension for 30 a day.
Preview text
Text from pages 1, 2, 3 of 15. Download the file for all 15 pages.
Answer: (Page 60) 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.
Q: Relation between RET and CALL is dependent or independent. Marks 2
Answer: (Page 64) 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.
Q: What is the difference between LES and LDS instruction? marks 3
Answer: (Page 97) 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.
MIDTERM FALL 2011
21. Write down the procedure to clear the selective bit. (Marks: 2)
Answer: (Page 59) 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.
22. Why REP prefix is generally not used with LODS instruction? (Marks: 2)
Answer: (Page 92) 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.
23. What is difference between REPE and REPNE? (Marks: 3)
Answer: (Page 93) 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.
24. Describe Push and Pop with the help of an example. (Marks: 3)
Answer: (Page 68) 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.
25. Explain all characteristics of SCAS instruction. (Marks: 5)
Answer: (Page 92) 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.
26. Describe Local Variable? (Marks: 5)
Answer: (Page 75) 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.
1. Which flag affected by often and operator
Answer: rep
- Explain divide overflow error.
Answer: (Page 85) 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.
- For what purpose "INT4" is reserved.
Answer: (Page 106) 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).
- Double working of Exchange instruction with help of an example.
Answer: (Page 73) xchg ax, [bx+si+2] ; exchange ax with second number
Q5. What is the difference between LES and LDS instruction?
Answer: rep
1. Two form of Moves introduction
2. Describe push & pop with help of example
Answer: (Page 71)
PUSH
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.(see stack)
POP
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.
- How value of Ip Register is saved & updated when call. Instruction executed.
Answer: (Page 16) 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.
Related CS401 files
All CS401 files →Get more out of VUBuddy, for free
- Unlimited downloads
- The explanation behind every MCQ answer
- Study offline on slow data
- 30 downloads a day instead of 3
- Sign in and buy Pro Semester here
One Pro Semester membership works in both the extension and the app.