CS401 – COMPUTER ARCHITECTURE AND ASSEMBLY
LANGUAGE PROGRAMMING (Session – 1 )
Q: Give the new values of AX and DX for each of the following instructions, or tell if
the overflow occurs. [2.5 x 4]
DIV BX, if DX contains 0x0000, AX contains 0x0007, and BX contains 0x0002
DIV BX, if DX contains 0x0000, AX contains 0xFFFF, and BX contains 0x0010
IDIV BX, if DX contains 0xFFFF, AX contains 0xFFFC, and BX contains 0x0003
DIV BX, if DX contains 0xFFFF, AX contains 0xFFFC, and BX contains 0x0003
Q: Fill in the Blanks
1) In the MOV instruction both operands i.e. source and the destination cannot be
2) The MOVZX instruction can be used only with _____________ integers.
3) Consider the following code segment
Write down the 16-bit value for cx in the space below
4) Name any two basic type of operands
5) The INC and Dec instruction do not effect the __________ flag
Q: Consider the following pseudo-code and write the corresponding assembly code for
Note: Try to write a shorter code.
If ( al>bl) AND (bl> cl)
cx = 1
Q: Give the value of the zero flag, the carry flag, the sign flag, and the overflow flag
after each of the following
instructions if AX is initialized with 0x1254 and BX is initialized with 0x0FFF.
a. add ax, 0xEDAB
b. add ax, bx
add bx, 0xF001
Q:Write a program to swap every pair of bits in the AX register.
For example If AX = 1001100110011001(binary)
Or AX= 0x9999 (hex)
Then after the program execution it must contain this value
AX = 0110011001100110 (binary)
AX= 0x6666 (hex)