CSE 322 Spring 2021 Lab 2

      No Comments on CSE 322 Spring 2021 Lab 2

Task #1

Write a program to (a) prompt the user, (b) read first, middle, and last initials of a person's name, and (c) display them down the
left margin.
Sample execution:
ENTER THREE INITIALS: JFK
J
F
K
//Solution
.MODEL small
.STACK 100H
.DATA
.CODE
MAIN Proc
    mov ah, 1
    int 21h
    mov bh, al
    int 21h   
    mov bl, al
    int 21h
    mov cl, al
    
    ;Print first initial
    mov ah, 2 
    mov dl, 0dh
    int 21h
    mov dl, 0ah
    int 21h
    mov dl, bh
    int 21h  
    ;Print second initial
    mov dl, 0dh
    int 21h
    mov dl, 0ah
    int 21h
    mov dl, bl
    int 21h     
    ;Print third initial
    mov dl, 0dh
    int 21h
    mov dl, 0ah
    int 21h
    mov dl, cl
    int 21h   
    
    ;Exit code
    mov ah, 4ch
    int 21h
    
    
endp MAIN

end MAIN

Task #2

Take 6 characters as input and print them in new lines.

//Solution
.MODEL small
.STACK 100H
.DATA  
a db ?,'$'  
b db ?,'$' 
c db ?,'$' 
d db ?,'$' 
e db ?,'$' 
f db ?,'$'        
.CODE
MAIN Proc
    mov ax, @data
    mov ds, ax 
    
    mov ah, 1
    int 21h 
    mov a, al
    int 21h 
    mov b, al  
    int 21h 
    mov c, al 
    int 21h 
    mov d, al 
    int 21h 
    mov e, al 
    int 21h 
    mov f, al     
    
    mov ah, 2  
    mov dl, 0dh
    int 21h
    mov dl, 0ah
    int 21h
    mov dl, a
    int 21h  
    mov dl, 0dh
    int 21h
    mov dl, 0ah
    int 21h  
    mov dl, b
    int 21h   
    mov dl, 0dh
    int 21h
    mov dl, 0ah
    int 21h
    mov dl, c
    int 21h    
    mov dl, 0dh
    int 21h
    mov dl, 0ah
    int 21h
    mov dl, d
    int 21h  
    mov dl, 0dh
    int 21h
    mov dl, 0ah
    int 21h
    mov dl, e
    int 21h   
    mov dl, 0dh
    int 21h
    mov dl, 0ah
    int 21h
    mov dl, f
    int 21h
    
    
    ;Exit code
    mov ah, 4ch
    int 21h
    
    
endp MAIN

end MAIN

Task #3

Write a program to draw a 10*10 solid box of star.

Sample Execution
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********
//Solution
.MODEL small
.STACK 100H
.DATA  
a db '**********',0dh,0ah,'$'       
.CODE
MAIN Proc
    mov ax, @data
    mov ds, ax 
    
    mov ah, 9
    lea dx, a
    int 21h  
    int 21h
    int 21h
    int 21h
    int 21h
    int 21h
    int 21h
    int 21h
    int 21h
    int 21h
    
    
    ;Exit code
    mov ah, 4ch
    int 21h
    
    
endp MAIN

end MAIN

Task #4

Write a program to draw a 10*10 hollow box of stars

Sample Execution
**********
*        *
*        *
*        *
*        *
*        *
*        *
*        *
*        *
**********
//Solution
//To be done by students

Task #5

Write a program to (a) display “?”, (b) read three initials,(c) display them in the middle of an 11 x 11 box of asterisks,

Sample Execution
?ABC
***********
***********
***********
***********
*****A*****
*****B*****
*****C*****
***********
***********
***********
***********
//Solution
//To be done by students

Task #6

Write a program to take a hexadecimal, A-F as input and print its equivalent decimal in the next line.

Sample Execution
A-10
B-11
C-12
E-13
//Solution
To be done by students

Leave a Reply

Your email address will not be published. Required fields are marked *