Question 1
a. Consider a machine language instruction that moves a copy of the content of register AX in the CPU to a memory location. What happens during the fetch and execute cycle?05
Ans:
b. A memory location has physical address 80FD2H. In what segment does it have offset BFD2H? 03
Ans: As we know,
Given,
Thus,
So, segment address 7500H have the offset address BFD2H.
c. In the microprocessor what is the function of the IP and the BIU?02
Ans: The Bus Interface unit (BIU) facilitates communication between the EU and the memory or I/O circuits. It is responsible for transmitting addresses, data, and control signals on the buses. Its registers are named CS, DS, ES, SS and IP; they hold addresses of memory locations. The IP (instruction pointer) contains the address of the next instruction to be executed by the EU.
Question 2
a. Describe the MOV and XCHG instruction with necessary syntax and example.05
Ans:
MOV: The MOV instruction is used to transfer data between registers, between a register and a memory location or to move directly into a register or memory location. The syntax is:
MOV destination, sourceHere are some examples:
MOV AX, BFD2H
MOV AX, BX
MOV CX, 3XCHG: The XCHG (exchange) operation is used to exchange the contents of two registers, or a register and a memory location. The syntax is:
XCHG destination, sourceAn example is:
XCHG AH, BLThis instruction swaps the contents of AH and BL, so that AH contains what was previously in BL and BL contains what was originally in AH.
b. What should be the status of flag registers after the execution of the following statement? Also write the result shown in the AX register after execution of the final instruction. 03
MOV AX, 7102H
MOV BX, 1024H
SUB AX, BX
NOT AX
INC AXAns: Execution of the instructions:
MOV AX, 7102H ; 0111 0001 0000 0010
MOV BX, 1024H ; 0001 0000 0010 0100
SUB AX, BX ; 0110 0000 1101 1110 -> 60DE
NOT AX ; 1001 1111 0010 0001 -> 9F21
INC AX ; 1001 1111 0010 0010 -> 9F22Status of the flag register:
| OF | SF | ZF | AF | PF | CF |
|---|---|---|---|---|---|
| 0 | 1 | 0 | 0 | 1 | 0 |
c. What are the differences between a register and a memory location?02
Ans: Differences between register and a memory location in 8086:
| Register | Memory Location |
|---|---|
Registers are 16-bit in size (AX,BX,CX,DX) | 8-bit (1 Byte ) in size |
Can be directly accessed by name (MOV AX, BX) | Requires Segment:Offset address to access |
Question 3
a. Write a sequence of instruction to do the following series: 05
Ans:
MOV AX, 0 ; Counter for Series
MOV BX, 0
MOV CX, 13 ; Defualt counter for LOOP
Continue:
INC AX ; Increment AX by 1
ADD BX, AX ; ADD BX with AX
LOOP Continue ; Continue LOOP untill CX=0
MOV AX, BX ; Store the sum of Series in AXb. Give a logic instruction to do each of the following:03
- Clear the even-number bits of
AXwhile leaving other bits unchanged. - Clear the sign bit of
ALwhile leaving the other bits unchanged.
Ans: 1.
AND AX, 1010101010101010b ; AND 0 -> ClearAND AL, 01111111b ; AND 0 -> Clearc. What are the flag conditions of JG, JNZ and JC?02
Ans:
| Symbol | Description | Condition |
|---|---|---|
JG | Jump if greater than | |
JNZ | Jump if not zero | |
JC | Jump if carry |
Question 4
a. Write an assembly language to find out the factorial of a number and compare it to a random number. If the factorial is above the number, it will store in CX otherwise it will store in DX register.05
Ans:
MOV AL, 1
MOV CX, 7 ; 7! and Counter for LOOP
factorial:
MUL CX ; AX = AL * CL
LOOP factorial ; Continue loop until CX = 0
CMP AX, 5D8FH ; Compare Factorial with a random num
; Update SF and ZF flag
JG above ; Jump if AX is greater
MOV DX, AX ; Move to DX if AX is smaller
HLT
above:
MOV CX, AX ; Move to CX if AX is greater
HLTb. Write down the significance of the following instructions. 03
IMUL BXDIV BLMOV AX, [BX][SI]
Ans:
IMUL BX: Signed multiplication ofAXwithBX. The higher 16-bit of the result is stored inDXregister and lower 16-bit is stored inAXregister.DXregister preserves the sign of the result.DIV BL: DivideAXbyBL. The quotient is stored inALregister while the reminder is stored inAHregister.MOV AX, [BX][SI]: Base plus Index addressing mode. The effective address is formed by adding the base registerBXand the index registerSI. The content of final effective address (BX+SI) is moved toAXregister.
c. How signed numbers are represented in microprocessor? Calculate the range of 4-bit number.02
Ans: Signed numbers are represented by 2’s compliment in microprocessor. The MSB acts as a sign bit.
The range of 4-bit positive number:
The range of 4-bit negative number (2’s Compliment):
Thus the range of 4-bit signed number is from .
Question 5
a. Explain SHL and SHL instructions mentioning the syntax with proper example.05
Ans:
SHL
The SHL (shift left) instruction shifts the bits in the destination to the left. The format for a single shift is:
SHL destination, 1For multiple shifts:
SHL destination, CL ; CL contains the number of shiftsA 0 is shifted into the rightmost bit position and the MSB is shifted into CF. Multiplies the value by 2 in each shift.
Example:
MOV AL, 10101001
MOV CL, 3
SHL AL, CL
SHR
The SHR (shift right) instruction shifts the bits in the destination to the right. The format for a single shift is:
SHR destination, 1For multiple shifts:
SHR destination, CL ; CL contains the number of shiftsA 0 is shifted into the MSB position and the rightmost is shifted into CF. Divides the value by 2 in each shift.
Example:
MOV AL, 10101001
MOV CL, 3
SHR AL, CL
b. Suppose DH contains 8AH, CF=1 and CL contains 3. What are the values of DH and CF after the instruction is executed:03
ROR DH, CLAns: The given instruction is rotate right (ROR). As CL contains 3, the ROR instruction will rotate the content of DH = 8AH along right side.
Thus, after the execution of the instruction, DH holds 51H = 01010001B and CF holds 0.
c. Distinguish between contents and address of a memory.02
Ans: The address of a memory location is a unique identification number that is assigned to each memory cell where as content is the actual data that is stored in that memory cell.
