Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

CONDITIONAL PROGRAMMING – 8088/8086 MICROPROCESSOR

To display a message, use lea (load effective address):


mov ah,09h
lea dx, Timeprompt
int 21h

09h of int 21h – display a character/string


01h of int 21h – accepts character input and place in into AL (byte), AX (word)
mov ah,01h
int 21h

CMP – compare (uses xor operation and affects the ZF bit)


JMP – Unconditional Jump
JE/JZ – Jump if Equal/Jump if Zero (conditional jump that jumps at a label when the
condition is TRUE/when ZF is SET)
cmp al,'Y'
je after

if AL = 0011 1101, Y = 0011 1101 and

AL xor Y operation was performed:

0011 1101

0011 1101
0000 0000 – ZF = 1
Label – procedures/sub-procedures or functions that can be jumped into when a certain
condition was met.
morn:
lea dx, mornmsg
mov ah,09h
int 21h
jmp exit

exit:
mov ah,4ch
int 21h
Program 1:
.model small
.stack 100h
.data

Timeprompt db " Is it After 12 noon (Y/N) ? ",13,10,"$"


mornmsg db "GOOD MORNING! ",13,10,"$"
aftermsg db "GOOD AFTERNOON! ",13,10,"$"

.code

mov ax,@data
mov ds,ax

mov ah,09h
lea dx, Timeprompt
int 21h

mov ah,01h
int 21h

cmp al,'Y'
je after
cmp al,'y'
je after
cmp al,'N'
je morn
cmp al,'n'
je morn
jmp error

after:
lea dx, aftermsg
mov ah,09h
int 21h
jmp exit

morn:
lea dx, mornmsg
mov ah,09h
int 21h
jmp exit

exit:
mov ah,4ch
int 21h

end
Program 2:
.model small
.stack 100h
.data

Timeprompt db " Is it After 12 noon (Y/N) ? ",13,10,"$"


mornmsg db "GOOD MORNING! ",13,10,"$"
aftermsg db "GOOD AFTERNOON! ",13,10,"$"
errormsg db "INVALID INPUT, Y or N Only !! ",13,10,"$"

.code
mov ax,@data
mov ds,ax

mov ah,09h
lea dx, Timeprompt
int 21h

mov ah,01h
int 21h

cmp al,'Y'
je after
cmp al,'y'
je after
cmp al,'N'
je morn
cmp al,'n'
je morn
jmp error

after:
lea dx,aftermsg
mov ah,09h
int 21h
jmp exit

morn:
lea dx,mornmsg
mov ah,09h
int 21h
jmp exit

error:
lea dx,errormsg
mov ah,09h
int 21h

exit:
mov ah,4ch
int 21h

end
Program 3:
.model small
.stack 100h
.data

Timeprompt db " Is it After 12 noon (Y/N) ? ",13,10,"$"


mornmsg db "GOOD MORNING! ",13,10,"$"
aftermsg db "GOOD AFTERNOON! ",13,10,"$"
errormsg db "INVALID INPUT, Y or N Only !! ",13,10,"$"

.code
mov ax,@data
mov ds,ax

start:
mov ah,09h
lea dx, Timeprompt
int 21h

mov ah,01h
int 21h

cmp al,'Y'
je after
cmp al,'y'
je after
cmp al,'N'
je morn
cmp al,'n'
je morn
jmp error

after:
lea dx,aftermsg
mov ah,09h
int 21h
jmp exit

morn:
lea dx,mornmsg
mov ah,09h
int 21h
jmp exit

error:
lea dx,errormsg
mov ah,09h
int 21h
jmp start

exit:
mov ah,4ch
int 21h

end

You might also like