0% found this document useful (0 votes)
8 views

Flow Control Instruction 4

The document contains code snippets for 4 different programs: 1. A program that takes 10 single character inputs and terminates if input is 'a' or exceeds 10 characters. 2. A program that displays 'O' if input is '1' or 'E' if input is '2', otherwise does nothing. 3. A program that displays 'E' for even inputs and 'O' for odd inputs. 4. A program that prints letters A-Z.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Flow Control Instruction 4

The document contains code snippets for 4 different programs: 1. A program that takes 10 single character inputs and terminates if input is 'a' or exceeds 10 characters. 2. A program that displays 'O' if input is '1' or 'E' if input is '2', otherwise does nothing. 3. A program that displays 'E' for even inputs and 'O' for odd inputs. 4. A program that prints letters A-Z.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Task 1:

Write a program to take 10 single-key inputs. Terminate the program if the number
of user
input keys exceed the given size or user inputs ‘a’.

.model small
.stack 100h
.data
.code

main proc
mov dx,@data
mov ds,dx

mov ah,1
mov cx,10

_block:
int 21h
cmp al,'a'
je _exit

loop _block

_exit:
mov ah,4ch
int 21h

main endp
*********************************************
Task 4:
Take a user input; if the input is character ‘1’ display ‘O’, if it is ‘2’, display
“E”, if it is anything
else, do nothing.

.model small
.stack 100h
.data
.code

main proc
mov dx,@data
mov ds,dx

mov ah,1
int 21h

cmp al,'1'
je _print1
cmp al,'2'
je _print2

jmp exit ;go to exit if input is none of the above

_print1:
mov ah,2
mov dl,'O'
int 21h
hlt

_print2:
mov ah,2
mov dl,'E'
int 21h
hlt

exit:
mov ah,4ch
int 21h

main endp
*******************************************************
******Even Odd*********

.model small
.stack 100h
.data
.code

main proc
mov dx,@data
mov ds,dx

mov ah,1
int 21h

test al,1
jz _print1

jmp _print2

jmp exit ;go to exit if input is none of the above

_print1:
mov ah,2
mov dl,'E'
int 21h
hlt

_print2:
mov ah,2
mov dl,'O'
int 21h
hlt

exit:
mov ah,4ch
int 21h

main endp
*****************************************************
*******print A to Z**********
.model small
.stack 100h
.code
mov ah,2
mov cx,26
mov dl,41h ;set dl value to 'A'

_loop:
int 21h
inc dl
mov bl,dl ;stores updated value of dl to bl
dec cx

mov dl,10
int 21h
mov dl,0dh
int 21h

mov dl,bl ;restores the value of dl after a line is created

jnz _loop

exit:
mov ah,4ch
int 21h
**************************************************
****count string*******
.model small
.stack 100h
.data
msg db "naureen$"

.code
main proc
mov ax,@data
mov ds,ax

mov ah,9
lea dx,msg
int 21h

mov cx,0
lea si,msg

traverse:
cmp [si],'$'
jz exit
inc cx
inc si
jmp traverse
exit:
mov ah,4ch
int 21h

main endp

You might also like