0% found this document useful (0 votes)
44 views5 pages

Lab 3

The document discusses topics related to loops, jumps, and interrupts that will be covered in a microprocessor interfacing and embedded systems lab. It provides examples of assembly language instructions like CMP, JZ, JNZ, JMP, and INT. It also includes tasks for students to copy, compile, and run code demonstrating concepts of jumps and arrays. It provides instructions for students to write a program to search an array for a value and print if it is found or not found.

Uploaded by

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

Lab 3

The document discusses topics related to loops, jumps, and interrupts that will be covered in a microprocessor interfacing and embedded systems lab. It provides examples of assembly language instructions like CMP, JZ, JNZ, JMP, and INT. It also includes tasks for students to copy, compile, and run code demonstrating concepts of jumps and arrays. It provides instructions for students to write a program to search an array for a value and print if it is found or not found.

Uploaded by

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

Summer 2020

CSE 331L: Microprocessor Interfacing & Embedded System Lab


Faculty: DR. DIHAN MD. NURUDDIN HASAN
Instructor: Moin Shahriyar
EEE 332/ CSE 331
Lab 3
Topic: Loops, Jump, Interrupt (I/O)

Topics to be covered in class today:


 Conditional Jumps/Unconditional Jumps
 Procedures
 Instructions:
 CMP = Compare
 AND/OR = Logic AND/OR operation
 JZ = Jump if Zero
 JNZ = Jump if not Zero
 JMP =(Unconditional) Jump
 INT = Interrupt

Instruction Operands Description


CMP REG, memory Compare.
memory, REG
REG, REG Algorithm:
memory,
immediate operand1 - operand2
REG, immediate
Result is not stored anywhere, flags are set (OF, SF, ZF, AF, PF,
CF) according to result.

Example:

MOV AL, 5
MOV BL, 5
CMP AL, BL; (AL = 5, ZF = 1 so equal!)

RET
Summer 2020

JZ Label Short Jump if Zero (equal). Set by CMP, SUB, ADD, TEST, AND,
OR, XOR instructions.

Algorithm:

if ZF = 1 then jump (ZF=Zero Flag. So, ZF=1 means it is 0)

Example:

include 'emu8086.inc'

ORG 100h

MOV AL, 5
CMP AL, 5
JZ label1
PRINT 'AL is not equal to 5.'
JMP exit
label1:
PRINT 'AL is equal to 5.'
exit:
RET
JNZ Label Short Jump if NOT Zero (equal). Set by CMP, SUB, ADD, TEST,
AND, OR, XOR instructions.

Algorithm:

if ZF = 0 then jump (ZF=Zero Flag. So, ZF=0 means it is 1[NOT


ZERO])

Example:

include 'emu8086.inc'

ORG 100h
MOV AL, 5
CMP AL, 5
JNZ label1
PRINT 'AL is equal to 5.'
JMP exit
label1:
PRINT 'AL is not equal to 5.'
exit:
RET
Summer 2020

JMP Label Unconditional Jump. Transfers control to another part of the


program. 4-byte address may be entered in this form:
1234h:5678h, first value is a segment second value is an
offset.

Algorithm:

always jump

Example:

include 'emu8086.inc'
ORG 100h
MOV AL, 5
JMP label1 ; jump over 2 lines!
PRINT 'Not Jumped!'
MOV AL, 0
label1:
PRINT 'Got Here!'
RET
INT Label Interrupt, used to take input or to show output.

Algorithm:
Halt the program to fulfill the interrupt depending on “ah”
register value.

Example:
org 100h
mov ah,1
int 21h
ret

Single Input ah=1


int 21h (al=input)
Single Output ah=2
int 21h (print dl as ascii)
Single Message/String Print: ah=9
dx->offset “string name”
int 21h
Summer 2020

Task 1 Task 2

Concept of JUMP: Concept of ARRAY:

Copy, compile and run the following code: Copy, compile and run the following code:

org 100h org 100h

jmp adder lea si,arr


mov cx,5

printer: search_loop:
mov ah,2
mov dl,al mov al,[si]
add dl,'0' cmp al,key
int 21h JZ found
jmp finish inc si
LOOP search_loop

adder:
mov al,2 ret
mov bl,2
add al,bl found:
jmp printer mov ah,9
mov dx,offset msg1
finish: int 21h

ret
ret

arr db 1,2,3,4,5
key db 9
msg1 db "Key is found$"
Summer 2020

Lab Assessment-1 10

Task 3

Write a program that will search for a specific value in an array and print “found” if
it is there and print “not found” if the value is not there.
Example:
Array: 1,2,5,6,7,8,9
Value: 3
“Not Found”
Value: 2
“Found”

Submission Procedure:
1. Name the file after your ID. E.G: 161123123
2. “Turn In” the file in Google Classroom under Lab Assessment section

You might also like