CS401-Assembly Language Solved Subjective From Midterm Papers May 04,2012
Muskaan
MIDTERM FALL 2011 CS401 Assembly LanguageQ: Affected flag of AND operation marks 2
Answer:- Affected Flag of AND are: CF, OF, PF, SF, ZF and AC
Q: Relation between RET and CALL is dependent or independent.
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 CS401 Assembly Language 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.
2
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.
MIDTERM SPRING 2011 CS401 Assembly Language
1. Which flag affected by often and operatorAnswer:- rep
2. 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.
3
3. For what purpose "INT4" is reserved.
Answer:- (Page 106)
INT4 is reserved for Arithmetic Overflow, change of sign bit
4. Double working of Exchange instruction with help of an example.
Answer:- (Page 73)
XCHG (Exchanges) instruction swaps the contents of the destination (first) and source (second) operands. The operands can be two general-purpose registers or a register and a memory location. If a memory operand is referenced, the processor's locking protocol is automatically implemented for the duration of the exchange operation, regardless of the presence or absence of the LOCK prefix or of the value of the IOPL. xchg ax, [bx+si+2] ; exchange ax with second number
5. What is the difference between LES and LDS instruction?
Answer:- rep
MIDTERM SPRING 2011 CS401 Assembly Language
1. Two form of Moves introductionAnswer: (Page 98)
MOVS has the two forms MOVSB and MOVSW 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. 3. How value of Ip Register is saved & updated when call. Instruction executed. Answer:- (Page 71) When Call instruction is executed the stack pointer (SP) is decremented by 2 and value of IP is pushed onto stack.
4
4. AX = 0x3412, BX=0x7856, CX= 0x1CAB, Sp=0x100 Give contents of AX, BX,CX,SP After creating instruction push AX, Push BX, cHG, AX,CX, POP CX 5. Explain Divide over Flows Error. Answer:- rep 6. How many parameters a subroutine can receive through stack. Answer:- (Page 72) The maximum parameters a subroutine can receive are seven MIDTERM SPRING 2011 CS401 Assembly Language what is push and pop explain with example 3marks Answer:- rep how the string instruction is used in the block of memory 3 Answer: (Page 92) 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. affected flag of AND operation 2marks Answer:- rep how to convert the 3 dimensional memory in 1 dimensional memory write the scas instruction 5marks Answer:- rep Midterm Paper Spring 2011 1. How many block processing instructions in 8088, just name the number of processing instructions? Answer:- (Page 91 ) 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
2. What are the instruction use by assembly language for permanent diversion and temporarily diversion?
Answer:- (Page 64)
The instructions for permanent diversion in 8088 are the jump instructions, while the instruction for temporary diversion is the CALL instruction.
3. How much string instructions are in assembly language? Write down all instructions
. Answer:- (Page 83 )
STOS – Clearing the Screen LODS – String Printing SCAS -String Length LES and LDS MOVS -Screen Scrolling CMPS – String Comparison
4. What is the purpose of following string instructions? a. STOS b. CMPS
Answer:- (Page 92 )
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.
Midterm Paper Spring 2011
1.For what purpose DS and ES registers are generally used in the context of video memory. 2 Marks
Answer:- (Page 81 )
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.
2.When the instructions “push ax” is executed in decrementing stack how the value of SP will change. 3 Marks
Answer: (Page 71)
When the instructions “push ax” is executed in decrementing stack, SP is decremented by two and IP is pushed onto the stack.
3.What colors are repeated by 0th, 1st and 2nd bits (from least significant side) in Attribute Byte? 3 Marks
Answer:- (Page 81)
blue , green , Red
4.How SCAS instructions can be used to detect Null at the end of a string? 5 Marks
Answer:-Page 95 (Not Sure)
We use SCASB with REPNE and a zero in AL to find a zero byte in the string. In CX we load the maximum possible size, which are 64K bytes. However actual strings will be much smaller. An important thing regarding SCAS and CMPS is that if they stop due to equality or inequality, the index registers have already incremented. Therefore when SCAS will stop DI would be pointing past the null character.
Midterm Paper Spring 2011
Q.No1: From where does the contents of SL and DS registers are loaded as a result of execution of the instruction of the instruction” LDS SL [BP +4]”? (2 marks)
Answer: (Page 97)
“lds si, [bp+4]” will load SI from BP+4 and DS from BP+6.
Q.No:2 .How 16-bit MUL operations is different from 32-bit MUL operation? (5 marks)
Answer: (Page 65)
If the operands were 16bit the answer would be in 32bit anf if the if the operands were 32bit the answer would be 64bit. For declaration of 16 bit we use “dw” and for 32-bit we use “dd”.
Q.No:4.Describe the working of the CALL instruction with the reference of Stack. (3 marks)
Answer:- (Page 68 )
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.
Midterm Paper Fall 2010
1.Explain the function of rotate right (ROR) instruction?
Answer:- (Page 53 )
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 flag.
2. Write all steps of algorithm for printing number 352.?
Answer:- (Page 84 )
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
3. Explain the complete operation of Interrupt when it is generated.?
Answer:- (Page 104 )
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.
MIDTERM EXAMINATION Spring 2010
Question No: 1 ( Marks: 2 ) What is difference between SHR and SAR instructions?
Answer:- (Page 52)
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: 2 ( Marks: 2 ) For what purpose "INT 1" is reserved?
Answer:- (Page 105)
INT 1, Trap, Single step Interrupt This interrupt is used in debugging with the trap flag. If the trap flag is set the Single Step Interrupt is generated after every instruction. By hooking this interrupt a debugger can get control after every instruction and display the registers etc. 8088 was the first processor that has this ability to support debugging.
Question No: 3 ( Marks: 2 ) Define implied operand?
Answer:- (Page 18)
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: 4 ( Marks: 5 ) Explain the process of ADC?
Answer:- (Page 57)
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.
(BEST OF LUCK)
0 comments:
Post a Comment