MIDTERM EXAMINATION
Spring 2010
CS401- Computer Architecture and Assembly Language Programming (Session - 3)
Time: 60 min
Marks: 38
Student Info | |
StudentID: | |
Center: | OPKST |
ExamDate: | 5/26/2010 12:00:00 AM |
For Teacher's Use Only | |||||||||
Q No. | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Total |
Marks | | | | | | | | | |
Q No. | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | |
Marks | | | | | | | | | |
Q No. | 17 | 18 | 19 | 20 | 21 | 22 | 23 | | |
Marks | | | | | | | | | |
Question No: 1 ( Marks: 1 ) - Please choose one
After the execution of SAR instruction
► The msb is replaced by a 0
► The msb is replaced by 1
► The msb retains its original value
► The msb is replaced by the value of CF
Question No: 2 ( Marks: 1 ) - Please choose one
RETF will pop the offset in the
► BP
► IP
► SP
► SI
Question No: 3 ( Marks: 1 ) - Please choose one
The routine that executes in response to an INT instruction is called
► ISR
► IRS
► ISP
► IRT
Question No: 4 ( Marks: 1 ) - Please choose one
The first instruction of “COM” file must be at offset:
► 0x0010
► 0x0100
► 0x1000
► 0x0000
Question No: 5 ( Marks: 1 ) - Please choose one
“Far” jump is not position relative but is _______________
► memory dependent
► Absolute
► temporary
► indirect
Question No: 6 ( Marks: 1 ) - Please choose one
Only ___________ instructions allow moving data from memory to memory.
► string
► word
► indirect
► stack
Question No: 7 ( Marks: 1 ) - Please choose one
After the execution of instruction “RET 2”
► SP is incremented by 2
► SP is decremented by 2
► SP is incremented by 4
► SP is decremented by 4
Question No: 8 ( Marks: 1 ) - Please choose one
DIV instruction has
► Two forms
► Three forms
► Four forms
► Five forms
Question No: 9 ( Marks: 1 ) - Please choose one
When the operand of DIV instruction is of 16 bits then implied dividend will be of
► 8 bits
► 16 bits
► 32 bits
► 64 bits
Question No: 10 ( Marks: 1 ) - Please choose one
After the execution of MOVS instruction which of the following registers are updated
► SI only
► DI only
► SI and DI only
► SI, DI and BP only
Question No: 11 ( Marks: 1 ) - Please choose one
In 8088 architecture, whenever an element is pushed on the stack
► SP is decremented by 1
► SP is decremented by 2
► SP is decremented by 3
► SP is decremented by 4
Question No: 12 ( Marks: 1 ) - Please choose one
When a very large number is divided by very small number so that the quotient is larger than the space provided, this is called
► Divide logical error
► Divide overflow error
► Divide syntax error
► An illegal instruction
Question No: 13 ( Marks: 1 ) - Please choose one
In the word designated for one screen location, the higher address contains
► The character code
► The attribute byte
► The parameters
► The dimensions
Question No: 14 ( Marks: 1 ) - Please choose one
Which of the following options contain the set of instructions to open a window to the video memory?
► mov AX, 0xb008
mov ES, AX
► mov AX, 0xb800
mov ES, AX
► mov AX, 0x8b00
mov ES, AX
► mov AX, 0x800b
mov ES, AX
Question No: 15 ( Marks: 1 ) - Please choose one
In a video memory, each screen location corresponds to
► One byte
► Two bytes
► Four bytes
► Eight bytes
Question No: 16 ( Marks: 1 ) - Please choose one
The execution of the instruction “mov word [ES : 0], 0x0741” will print character “A” on screen , background color of the screen will be
► Black
► White
► Red
► Blue
Question No: 17 ( Marks: 2 )
Why is it necessary to provide the segment and offset address in case of FAR jump ?
Segment and offset must be given to a far jump. Because, sometimes we may need to go from one code segment to another, and near and short jumps cannot take us there. Far jump must be used and a two byte segment and a two byte offset are given to it. It loads CS with the segment part and IP with the offset part.
Question No: 18 ( Marks: 2 )
What’s your understanding about Incrementing and Decrementing Stack?
Whenever an element is pushed on the stack SP is decremented by two and whenever an element is popped on the stack SP is incremented by two.
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.
As the 8088 stack works on word sized elements. Single bytes cannot be pushed or popped from the stack.
Question No: 19 ( Marks: 2 )
Number2:
IF DF=0 what its represent and IF DF=1 what its represent ?
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 autoincrement mode of string instruction, and if DF is set, DF=1, this is called the autodecrement mode. There are two instructions to set and clear the direction flag.
Question No: 20 ( Marks: 3 )
What is the Difference between CALL and RET
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: 21 ( Marks: 3 )
Tell the Formula to scroll up the screen
rep movsw scroll up
scrollup: push bp
mov bp,sp
push ax
push cx
push si
push di
push es
push ds
mov ax, 80 ; load chars per row in ax
mul byte [bp+4] ; calculate source position
mov si, ax ; load source position in si
push si ; save position for later use
shl si, 1 ; convert to byte offset
mov cx, 2000 ; number of screen locations
sub cx, ax ; count of words to move
mov ax, 0xb800
mov es, ax ; point es to video base
mov ds, ax ; point ds to video base
xor di, di ; point di to top left column
cld ; set auto increment mode
rep movsw ; scroll up
mov ax, 0x0720 ; space in normal attribute
pop cx ; count of positions to clear
rep stosw ; clear the scrolled space
pop ds
pop es
pop di
pop si
pop cx
pop ax
pop bp
ret 2
Question No: 22 ( Marks: 5 )
Explain how extended shifting is performed
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.
Question No: 23 ( Marks: 5 )
Write a subroutine to calculate the string length.?
subroutine to calculate the length of a string
; takes the segment and offset of a string as parameters
strlen: push bp
mov bp,sp
push es
push cx
push di
les di, [bp+4] ; point es:di to string
mov cx, 0xffff ; load maximum number in cx
xor al, al ; load a zero in al
repne scasb ; find zero in the string
mov ax, 0xffff ; load maximum number in ax
sub ax, cx ; find change in cx
dec ax ; exclude null from length
pop di
pop cx
pop es
pop bp
ret 4
Another Paper:-
CS4O1 Computer Architecture and Assembly Language
Programming
Mid Term Examination - May 2010
16 MCQs of one number each. Few MCQs & long Questions recalled and are reproduced here.
1. Immediate operands of Push are called:
a Source Operands
b. Destination Operands
c. Data Operands
d. Stack Operands
2. Extended ASCII has how many characters:
a 64
b. 128
c. 256
d. 512
3. The video attribute byte of Red component of foreground color is:-
a. 2
b. 3
c. 4
d. 5
4. Process of sending signals bak & forth is called:
a Programming
b. Activity
c. Interruption
d. Communication
5. 32 Bit Processor has an accumulator of:
a 8 Bits
b. 16 Bits
c. 32 Bits
d. 64 Bits
6. When a relative address is stored in 16 Bits then the jump is known as:-
a. Near
h. Short
c. Far
d. Close
7. In order to convert digit into ASCII value following is added:
a 0x20
b. 0x30
c. 0x40
d. OxlOO
8. Replace following invalid instructions with single valid instruction:- 2 Marks
a. Mov IP
b. Mov IP, L5
9. How String instructions work on a block of memory? 3 Marks
10. What is mismatch defme with one example? 3 Marks
11. Define what LES & LDS Instruction do? 3 Marks
12. Another Question about moving data and its effect on different registers. 5 Marks
13. Write a sub routine to clear screen? 5 Marks
No comments:
Post a Comment