CAO Practicals
CAO Practicals
This instruction moves the hexadecimal value 0A5H into the lower 8 bits of register BL.
MOV CL, 4: This instruction moves the decimal value 4 into register CL. This value will be used as the
count for the bitwise rotation operation.
ROL BL, CL: This instruction performs a rotate left operation on the value in BL by the count specified in
CL.
During a rotate left operation, all bits in the operand are shifted left by the specified count. The bit that
is shifted out of the most significant bit (MSB) position is wrapped around and inserted into the least
significant bit (LSB) position.
2.MOV BL, 90H: This instruction moves the hexadecimal value 90H into the lower 8 bits of register BL.
MOV CL, 4: This instruction moves the decimal value 4 into register CL.
ROR BL, CL: This instruction performs a rotate right operation on the value in BL by the count specified in
CL. During a rotate right operation, all bits in the operand are shifted right by the specified count. The bit
that is shifted out of the least significant bit position is wrapped around and inserted into the most
significant bit position.
After the ROR operation: Therefore, after the code executes, the value in BL will be modified to 09H and
no flags were triggered.
MOV BL, 0A4H: This instruction moves the hexadecimal value into the lower 8 bits of register BL.
RCL BL, 1: This instruction performs a rotate carry left operation on the value in BL by 1 bit.
The value of the Carry Flag before the rotation is shifted into the most significant bit of BL.
The Overflow Flag gets triggered because an arithmetic overflow has occurred in an operation,
indicating that the signed two's-complement result would not fit in the number of bits used for the
result.
The first RCL shifts the bits in BL and since CF was 0, a 0 is inserted into the MSB, setting CF to 1.
The second RCL again shifts the bits, this time the previous CF (1) is shifted out, setting CF back to 0, and
the original MSB bit of BL is shifted into the CF.
4.MOV AX, 1025H: This instruction moves the hexadecimal value 1025H into register AX.
MOV BX, 475AH: This instruction moves the hexadecimal value 475AH into register BX.
MOV CX, 50H: This instruction moves the hexadecimal value 50H into register CX.
Loop (Lev):
The PF was triggered because the result stored in BX had an even number of 1s.
LOOP Lev: This instruction performs a loop operation. It decrements the value in register CX by 1.
If the value in CX is not zero (meaning there are still iterations left), the program jumps back to the
instruction labeled Lev, effectively repeating the loop body.
Termination:
RET: This instruction returns from the current code block. It retrieves the return address that was
previously pushed onto the stack when the loop function was called and jumps back to that location,
finishing the execution of this code.
Summary:
This code creates a loop that iterates using the initial value in CX. In each iteration:
5.MOV AX, 1234H: This instruction moves the hexadecimal value 1234H into register AX.
MOV BX, 3456H: This instruction moves the hexadecimal value 3456H into register BX.
JMP ABC: This instruction jumps to the instruction labeled ABC. This means the code execution skips the
instruction MOV CX, 3456H and directly goes to the label.
Label ABC:
MOV DX, 5678H: This instruction moves the hexadecimal value into register DX.
Due to the JMP ABC instruction, the line MOV CX, 3456H is not executed.
The program jumps directly to the label ABC and executes the instruction MOV DX, 5678H.
MOV BX, 1234H: This instruction moves the same value into register BX.
XOR AX, BX: This instruction performs a bitwise XOR operation between the values in AX and BX. Since
both registers have the same value (1234H), the XOR operation will result in all bits being 0.
The PF was triggered because the result stored in AX had an even number of 1s.
JZ ABC: This instruction performs a conditional jump based on the Zero Flag (ZF). Since the XOR
operation resulted in zero, the ZF will be set. The JZ (Jump if Zero) instruction then jumps to the
instruction labeled ABC.
HLT: This instruction (if executed) would halt the program execution. However, similar to line 5, this HLT
is not executed due to the jump.
MOV DX, 1234H: This instruction, located at the label ABC, moves the value 1234H into register DX.
HLT: This HLT instruction, located at the label ABC, halts the program execution.
Conclusion:
Since the values in AX and BX are the same, the XOR operation results in zero, setting the Zero Flag. This
triggers the JZ instruction to jump to the ABC label. Therefore:
The program execution halts at the HLT instruction located at the ABC label.
7.MOV AX, 1233H: This instruction moves the hexadecimal value 1233H into register AX.
MOV BX, 1234H: This instruction moves the value 1234H into register BX.
XOR AX, BX: This instruction performs a bitwise XOR operation between the values in AX (1233H) and BX
(1234H).
The XOR operation results in a value of 01H (decimal 1) because the corresponding bits that differ (LSB)
result in a 1, and all other bits being the same result in 0s.
JZ ABC: This instruction performs a conditional jump based on the Zero Flag (ZF). Since the XOR
operation did not result in zero, the ZF will be cleared. The JZ (Jump if Zero) instruction will not jump in
this case, and the program continues to the next line.
MOV CX, 1234H: This instruction, unlike the previous case, will now be executed because there was no
jump. It moves the value 1234H into register CX.
Because the program was halted, all other lines of code were not executed.