0% found this document useful (0 votes)
54 views4 pages

Lab 3

Lab 3

Uploaded by

mujtabajamal2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views4 pages

Lab 3

Lab 3

Uploaded by

mujtabajamal2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Department of Computer Engineering

Microprocessors and Microcontroller Interfacing Lab

Course Instructor: Dated:

Lab Engineer:

Semester

Lab 3 x86 assembly program with jumps – Part 1

Total Manual Obtained


Name Roll No
Marks (35) Marks (15) Marks (50)

Checked on: _______________________________

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 −

MOV AX, 00 ; Initializing AX to 0


MOV BX, 00 ; Initializing BX to 0
MOV CX, 01 ; Initializing CX to 1
L20:
MOV AX, 01 ; Increment AX
MOV BX, AX ; Add AX to BX
JMP L20 ; repeats the statements
2. Conditional jump
This is performed by a set of jump instructions j<condition> depending upon the
condition. The conditional instructions transfer the control by breaking the sequential
flow and they do it by changing the offset value in IP.

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

Registers Value Steps

CX MOV CX,5

EBX MOV EBX, OFFSET DATA_IN

AX MOV AX,0

AX ADD AX, [EBX]

EBX INC EBX


INC EBX

CX DEC CX

SUM MOV SUM, AX

3. Modify the task 2 code for double word inputs and paste it here.

You might also like