Lab 3
Lab 3
Lab 3
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:
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:
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
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
Task 1 Task 2
Copy, compile and run the following code: Copy, compile and run the following code:
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