Experiment No: 01
Experiment Name: To load the machine codes of a sample program to MDA -
8086, execution of instruction in single step mode and verification of results.
Objectives: The objectives of this experiment are-
i) To learn the procedure of loading program in RAM of MDA-8086 in
“Machine Code” mode.
ii) To load the program to MDA-8086, execute the program in single
step mode and verify the result.
Instructions:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
ORG 1000H
MOV AX, 805EH
MOV DX, 0540H
MOV CL, 02H
MOV CH, 91H
ADD AX, DX
MOV BX, 0050H
SUB AX, BX
INC DL
DEC BX
XCHG CX, BX
HLT
CODE ENDS
END
C213094 – KAZI IRFANUL KARIM
Program Descriptions:
Program Description
CODE SEGMENT Initializing the program.
ASSUME CS: CODE, DS: CODE
ORG 1000H Program start from 1000H memory location.
So starting address is 1000H.
MOV AX,805EH The source value 805E will copy into the
destination AX.
MOV DX,0540H The source value 0540H will copy into the
destination DX.
MOV CL, 02H The source value 02H will copy into the
destination CL.
MOV CH, 91H The source value 91H will copy into the
destination CH.
ADD AX, DX Sum of AX and DX registers and then the
result will store in AX register.
MOV BX, 0050H The Source Value 0050H will copy into the
destination BX.
SUB AX, BX Subtract AX from BX and place the result in
AX.
INC DL Increment the value of DL with 1.
DEC BX Decrement the value of BX with 1.
XCHG CX, BX Exchange the values between CX and BX.
HLT The program will stop.
END Closing the program.
C213094 – KAZI IRFANUL KARIM
Data Table:
Program AX BX CX DX FLAGS
MOV AX,805EH 805E 0000 0000 0000 IF - 1
MOV DX,0540H 805E 0000 0000 0540 IF - 1
MOV CL, 02H 805E 0000 0002 0540 IF - 1
MOV CH, 91H 805E 0000 9102 0540 IF - 1
ADD AX, DX 859E 0000 9102 0540 IF-1, SF-1
MOV BX, 0050H 859E 0050 9102 0540 IF-1, SF-1
SUB AX, BX 854E 0050 9102 0540 IF-1, SF-1,
PF-1
INC DL 854E 0050 9102 0541 IF-1, PF-1
DEC BX 854E 004F 9102 0541 IF-1, AF-1
XCHG CX, BX 854E 9102 004F 0541 IF-1, AF-1
HLT The emulation is halted
Program Verification:
MOV AX, 805EH: The source value 805EH will copy into destination register
AX. We saw in simulation, after execution AX is 805EH.
MOV DX, 0540H: The source value 0540H will copy into destination DX. We
saw in emulator, after execution DX is 0540H.
MOV CL, 02H: The source value 02H will copy into destination register CL.
We saw in emulator, after execution CL is 02H.
MOV CH, 91H: The source value 91H will copy into destination CH. We saw in
emulator, after execution CH is 91H.
ADD AX, DX: The sum of AX and DX will store in AX. So, AX will be 805EH +
0540H = 859EH. We can see that in emulator after the execution, AX has the
same result.
MOV BX, 0050H: After execution, the value of BX will be 0050H.
C213094 – KAZI IRFANUL KARIM
SUB AX, BX: After subtracting the value of BX from AX, it stored the result in
AX. So, AX= AX – BX = 859EH – 0050H = 854EH. This is the result showed by
the emulator in AX register, after the operation.
INC DL: Value of DL will increase by 1. So, the value of DL will become 40 + 1
= 41H.
DEC BX: Value of BX will decrease by 1 and the result will be BX = 0050H – 1 =
004FH.
XCHG CX, BX: The value of CX and BX will be swapped. So CX will be 004FH
and BX will be 9102H.
HLT: The Program will stop here.
Emulation Screenshots:
C213094 – KAZI IRFANUL KARIM
C213094 – KAZI IRFANUL KARIM
C213094 – KAZI IRFANUL KARIM
Discussion:
In this experiment, we have learnt the procedure of loading program in MDA-
8086 in machine code mode. And we also learnt how to execute the program
in single step mode and verify the result. In this experiment we use emulator
software to familiar with data movement, addition, subtraction, increment,
decrement, exchange. We execute the sample program in emulator 8086
software and verify the result too.
C213094 – KAZI IRFANUL KARIM
Experiment No: 02
Experiment Name: Logic operations in assembly language.
Objectives: Objective of this experiment are-
i) To understand the fundamental principles of logic operations
in microprocessor programming.
ii) To learn how to perform basic logic operations such as AND,
OR, XOR, and NOT in assembly language.
iii) To gain practical experience in writing assembly language
code to implement logic operations.
iv) To study the impact of logic operations on data manipulation
and program flow.
Instructions:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
ORG 1000H
MOV AX, 1027H
MOV BX, 5A27H
MOV CX, 54A5H
OR AX, BX
XOR AX, CX
NOT AX
TEST CX, BX
AND CX, AX
HLT
CODE ENDS
END
C213094 – KAZI IRFANUL KARIM
Program Descriptions:
Program Description
CODE SEGMENT Initializing the program.
ASSUME CS: CODE, DS: CODE
ORG 1000H Program start from 1000H memory location.
So starting address is 1000H.
MOV AX, 1027H The source value 1027H will copy into the
destination AX.
MOV BX, 5A27H The source value 5A27H will copy into the
destination BX.
MOV CX, 54A5H The source value 54A5H will copy into the
destination CX.
OR AX, BX Logical OR operation will happen between
AX and BX then the result will stored in AX.
XOR AX, CX Logical XOR operation will happen between
AX and CX then the result will store in AX.
NOT AX This operation Invert the value of AX.
TEST CX, BX CX and BX will not change but ALU result
and flags will be changed as OR operation.
AND CX, AX Logical AND operation will happen between
CX and AX, and the result will stored in CX.
HLT The program will stop.
END Closing the program.
C213094 – KAZI IRFANUL KARIM
Data Table:
Program AX BX CX DX FLAGS
MOV AX, 1027H 1027 0000 0000 0000 IF - 1
MOV BX, 5A27H 1027 5A27 0000 0000 IF - 1
MOV CX, 54A5H 1027 5A27 54A5 0000 IF - 1
OR AX, BX 5A27 5A27 54A5 0000 IF – 1, PF-1
XOR AX, CX 0E82 5A27 54A5 0000 IF-1, PF-1
NOT AX F17D 5A27 54A5 0000 IF-1, PF-1
TEST CX, BX F17D 5A27 54A5 0000 IF-1
AND CX, AX F17D 5A27 5025 0000 IF-1
HLT The emulation is halted
Program Verification:
MOV AX, 1027H: The source value 1027H will copy into destination register
AX. We saw in simulation, after execution AX is 1027H.
MOV BX, 5A27H: The source value 5A27H will copy into destination BX. We
saw in emulator, after execution BX is 5A27H.
MOV CX, 54A5H: The source value 54A5H will copy into destination register
CX. We saw in emulator, after execution CX is 54A5H.
OR AX, BX: Logical OR operation will happen between AX and BX then the
result will store in AX, So the value of AX will become 5A27H and the ALU will
generate even parity flag.
C213094 – KAZI IRFANUL KARIM
XOR AX, CX: Logical XOR operation will happen between AX and CX then the
result will store in AX, and the value of AX will become 0E82. We saw that in
emulator.
NOT AX: This operation Invert the value of AX as F17D.
TEST CX, BX: CX and BX will not change but ALU result and flags will be
changed as OR operation. So the parity flag will be 0 after this operation.
AND CX, AX: Logical AND operation will happen between CX and AX, and the
result will stored in CX. Now value of CX will be 5025H.
HLT: The Program will stop here.
Emulation Screenshots:
C213094 – KAZI IRFANUL KARIM
C213094 – KAZI IRFANUL KARIM
Discussion:
In this lab, we successfully implemented logic operations in assembly
language using x86 instructions. These operations are fundamental for
performing various tasks in low-level programming. We observed that logical
AND, OR, XOR, and NOT operations are essential for data manipulation and
decision-making in assembly language.
C213094 – KAZI IRFANUL KARIM
Experiment No: 03
Experiment Name: Experimental study on program control instructions using
conditional jump.
Objectives: Objective of this experiment are-
I. To understand the concept and significance of conditional jump
instructions.
II. To implement conditional jump instructions using x86 assembly
language.
III. To experiment with different conditions and scenarios for conditional
jumps.
IV. To analyze and document the behavior and outcomes of conditional
jumps.
Instructions:
CODE SEGMENT
ASSUME CS: CODE, DS: CODE
ORG 1000H
MOV AX, 7A24H
MOV BX, 95A3H
ADD AX, BX
JC IIUC
CSE: OR AX, 23H
JNZ LAST
IIUC: MOV CX, 0FC7H
SUB AX, CX
JZ CSE
LAST: HLT
CODE ENDS
END
C213094 – KAZI IRFANUL KARIM
Program Descriptions:
Program Description
CODE SEGMENT Initializing the program.
ASSUME CS: CODE, DS: CODE
ORG 1000H Program start from 1000H memory location.
So starting address is 1000H.
MOV AX, 7A24H The source value 7A24H will copy into the
destination AX.
MOV BX, 95A3H The source value 95A3H will copy into the
destination BX.
ADD AX, BX Addition operation of AX and BX, and the
result will place in AX.
JC IIUC JC Stands for 'Jump if Carry' It will checks
whether the carry flag is set or not. If CF = 1,
then jump to IIUC.
CSE: OR AX, 23H This is a destination for a jump and here
logical OR operation will happen between
AX and 23H. The result will store in AX.
JNZ LAST JNZ Stands for 'Jump if Not Zero' It checks
whether the zero flag is reset or not. If ZF =
0, then jump to LAST.
IIUC: MOV CX, 0FC7H It is a destination for a Jump and here the
value 0FC7H will assign into CX.
SUB AX, CX Subtract CX from AX and the result will place
in AX.
JZ CSE JZ Stands for 'Jump if Zero' It checks whether
the zero flag is set or not. If yes, then jump
takes place, that is: If ZF = 1, then jump to
CSE
LAST: HLT This is also a destination of jump, here the
program will stop.
CODE ENDS Closing the program.
C213094 – KAZI IRFANUL KARIM
Data Table:
Program AX BX CX DX FLAGS
MOV AX, 7A24H 7A24 0000 0000 0000 IF - 1
MOV BX, 95A3H 7A24 95A3 0000 0000 IF - 1
ADD AX, BX 0FC7 95A3 0000 0000 IF – 1, CF-1
JC IIUC 0FC7 95A3 0000 0000 IF – 1, CF-1
CSE: OR AX, 23H 0023 5A27 54A5 0000 IF - 1
JNZ LAST 0023 5A27 54A5 0000 IF - 1
IIUC: MOV CX,0FC7H 0FC7 95A3 0FC7 0000 IF – 1, CF-1
SUB AX, CX 0000 95A3 0FC7 0000 IF – 1, CF-1,
ZF – 1
JZ CSE 0000 95A3 0FC7 0000 IF – 1, CF-1,
ZF – 1
LAST: HLT The emulation is halted
Program Verification:
MOV AX, 7A24H: The source value 7A24H will copy into destination register
AX. We saw in simulation, after execution AX is 7A24H.
MOV BX, 95A3H: The source value 95A3H will copy into destination register
BX. We saw in simulation, after execution BX is 95A3H.
ADD AX, BX: Addition operation will happen between AX and BX and the
result of the operation will placed in AX. We can see that in emulator that AX
= AX + BX = 7A24H + 95A3H = 0FC7H
JC IIUC: This is the instruction for conditional jump ‘jump if carry’. We saw in
emulator that the carry flag CF=1 after doing previous operation. So the
program will jump to the destination IIUC cause CF=1.
C213094 – KAZI IRFANUL KARIM
CSE: OR AX, 23H: We can see in the emulator that logical OR operation is
happening between AX and 23H, the result of this operation is 0023H which
is stored in the AX register.
JNZ LAST: This is also a conditional jump that refers ‘Jump if not equal zero’.
It will check whether the zero flag is active or not. If zero flag is not active ,
then the program will jump to the destination LAST.
IIUC: MOV CX, 0FC7H: The source value 0FC7H will copy into destination
register CX. We saw in simulation, after execution CX is 0FC7H.
SUB AX, CX: CX will be subtracted from AX and the result will placed in AX.
JZ CSE: This is a conditional Jump instruction which refers ‘Jump if zero’. It
will check the zero flag is active or not. If zero flag is active it will jump to
destination CSE.
LAST: HLT: The program is halted.
Emulation Screenshots:
C213094 – KAZI IRFANUL KARIM
C213094 – KAZI IRFANUL KARIM
C213094 – KAZI IRFANUL KARIM
Discussion:
The results of this experiment emphasize the significance of conditional jump
instructions in program control and decision-making processes. Conditional
jumps enable programs to make choices and execute different code paths
based on specific conditions. The observed variations in execution time and
branching behavior underscore the dynamic nature of program control
facilitated by conditional jumps. Conditional jump instructions are essential
for implementing features such as error handling, user input validation, and
decision-making. Understanding their behavior and impact on program
execution is crucial for writing efficient and functional software.
C213094 – KAZI IRFANUL KARIM