Lab 3
Lab 3
Lab Engineer:
Semester
Signature: __________________________________
3 x86 assembly program with jumps – Part 1
Introduction
This lab expands on last session’s concept of arrays to demonstrate the use of transfer of
control instructions in assembly language i.e., unconditional and conditional jump.
Lab goals
This lab will enable students to achieve the following:
1. Define uninitialized variables
2. Use unconditional jump instructions to manipulate array data
3. Use conditional jump instructions to manipulate array data
Lab conduct
1. You have to perform this experiment using Visual Studio 2015.
2. You are required to work in groups; everyone must attempt to understand the
assembly language syntax and programming.
3. In case some aspect of the lab experiment is not understood, you are advised to seek
help from the instructor, lab engineer or the TA.
4. Every student has to submit individual lab manual in printed form. Use the provided
Word document to fill the manual and convert it to PDF before printing.
Lab details
1. Unconditional jump
This is performed by the JMP instruction. Conditional execution often involves a
transfer of control to the address of an instruction that does not follow the currently
executing instruction. Transfer of control may be forward, to execute a new set of
instructions or backward, to re-execute the same steps.
Example
The following code snippet illustrates the JMP instruction −
Example
The following code snippet illustrates the JMP instruction −
JZ L1 ; jump if ZF = 1
.
.
L1:
.
.
Lab tasks
1. Execute the following task. Fill out the table given below
.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.data
DATA_IN WORD 1H,2H,3H,4H,5H
SUM WORD ?
.code
main PROC
mov eax, 15;
jmp First
Second:
mov eax, 10
jmp Third
First:
mov ebx, eax
jmp Second
Third:
mov ecx, eax
INVOKE ExitProcess,0
main ENDP
END main
REGISTERS VALUE
EAX
EBX
ECX
2. Execute the following task. Fill out the table given below for each loop. Screenshot of
your simulation
.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.data
DATA_IN WORD 1H,2H,3H,4H,5H
SUM WORD ?
.code
main PROC
MOV CX,5
MOV EBX, OFFSET DATA_IN
MOV AX,0
AGAIN:
ADD AX, [EBX]
INC EBX
INC EBX
DEC CX
JNZ AGAIN
MOV SUM, AX
INVOKE ExitProcess,0
main ENDP
END main
CX MOV CX,5
AX MOV AX,0
CX DEC CX
3. Modify the task 2 code for double word inputs and paste it here.