For each of the following problem you should take a number (Range: 1 -
9)as size of the pattern. Your task is to print the patterns.
1)Right Angled Triangle with ‘*’: For input 9 following will be printed
2) Reversed Right Angled Triangle with ‘*’: For input 9 following will be printed
3) Pyramid with ‘*’: For input 9 following will be printed
4) Reversed Right Angled Triangle with Numbers: For input 9 following will be
printed
For input 6 following will be printed
5) Reversed Right Angled Triangle with Numbers: For input 9 following will be
printed
6) Pyramid with Numbers: For input 9 following will be printed
For input 6 following will be printed
=============================Solution===============================
Assignment-1
********************************************
.MODEL SMALL
.STACK 100H
.DATA
CR EQU 0DH ;CARRIGE RETURN NEW LINE
LF EQU 0AH ;LINEFREED
MSG1 DB 'I AM AMIT$'
NEWLINE DB CR,LF ,'$'
I DB ?
J DB ?
N DB ?
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS ,AX
MOV AH,01H ;INPUT
INT 21H
MOV N,AL
MOV AH,9 ;INPUT AFTER NEWLINE
LEA DX,NEWLINE
INT 21H
MOV I,'1'
LOOP1:
MOV AL,N
CMP I,AL
MOV J,'1'
JLE LOOP2
INCRE1:
MOV AL,01H ;INCREAMENT
ADD I,AL
MOV AL,N
CMP I,AL
MOV AH,9 ;PRINT NEWLINE
LEA DX,NEWLINE
INT 21H
JG EXIT
JMP LOOP1
LOOP2:
MOV AL,I
CMP J,AL
JLE PRINTSTAR
INCRE2:
MOV AL,1
ADD J,AL
MOV AL,I
CMP J,AL
JG INCRE1
JMP LOOP2
PRINTSTAR:
MOV AH,2
MOV DL,'*'
INT 21H
JMP INCRE2
EXIT:
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN
************************************
Assignment-2
***********************************
.MODEL SMALL
.STACK 100H
.DATA
CR EQU 0DH ;CARRIGE RETURN NEW LINE
LF EQU 0AH ;LINEFREED
MSG1 DB 'I AM AMIT$'
NEWLINE DB CR,LF ,'$'
I DB ?
J DB ?
N DB ?
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS ,AX
MOV AH,01H ;INPUT
INT 21H
MOV N,AL
MOV AH,9 ;INPUT AFTER NEWLINE
LEA DX,NEWLINE
INT 21H
MOV I,'1'
LOOP1:
MOV AL,I
MOV J,AL
MOV AL,N
CMP I,AL
JLE LOOP2
INCRE1:
MOV AL,01H ;INCREAMENT
ADD I,AL
MOV AL,N
CMP I,AL
MOV AH,9 ;PRINT NEWLINE
LEA DX,NEWLINE
INT 21H
JG EXIT
JMP LOOP1
LOOP2:
MOV AL,N
CMP J,AL
JLE PRINTSTAR
INCRE2:
MOV AL,1
ADD J,AL
MOV AL,N
CMP J,AL
JG INCRE1
JMP LOOP2
PRINTSTAR:
MOV AH,2
MOV DL,'*'
INT 21H
JMP INCRE2
EXIT:
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN
******************************************************
Assignment-3
******************************************************
.MODEL SMALL
.STACK 100H
.DATA
CR EQU 0DH ;CARRIGE RETURN NEW LINE
LF EQU 0AH ;LINEFREED
MSG1 DB 'I AM AMIT$'
NEWLINE DB CR,LF ,'$'
I DB ?
J DB ?
K DB ?
L DB ?
N DB ?
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS ,AX
MOV AH,01H ;INPUT
INT 21H
MOV N,AL
MOV AH,9 ;INPUT AFTER NEWLINE
LEA DX,NEWLINE
INT 21H
MOV I,'1'
LOOP1:
MOV AL,I ;J=I
MOV J,AL
MOV AL,'1' ;K=1
MOV K,AL
MOV L,AL ;L=1
MOV AL,N
CMP I,AL
JLE LOOP2
INCRE1:
MOV AL,01H ;INCREAMENT
ADD I,AL
MOV AL,N
CMP I,AL
MOV AH,9 ;PRINT NEWLINE
LEA DX,NEWLINE
INT 21H
JG EXIT
JMP LOOP1
LOOP2:
MOV AL,N
CMP J,AL
JL PRINTSPACE
INCRE2:
MOV AL,1
ADD J,AL
MOV AL,N
CMP J,AL
JGE LOOP3 ;;;;
JMP LOOP2
LOOP3:
MOV AL,I
CMP K,AL
JLE PRINTSTAR
INCRE3:
MOV AL,01H
ADD K,AL
MOV AL,I
CMP K,AL
JG LOOP4
JMP LOOP3
LOOP4:
MOV AL,I
CMP L,AL
JL PRINTSTAR4
INCRE4:
MOV AL,01H
ADD L,AL
MOV AL,I
CMP L,AL
JGE INCRE1
JMP LOOP4
PRINTSPACE:
MOV AH,2
MOV DL,' '
INT 21H
JMP INCRE2
PRINTSTAR:
MOV AH,2
MOV DL,'*'
INT 21H
JMP INCRE3
PRINTSTAR4:
MOV AH,2
MOV DL,'*'
INT 21H
JMP INCRE4
EXIT:
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN
*****************************************************
Assignment-4
*****************************************************
.MODEL SMALL
.STACK 100H
.DATA
CR EQU 0DH ;CARRIGE RETURN NEW LINE
LF EQU 0AH ;LINEFREED
NEWLINE DB CR,LF ,'$'
I DB ?
J DB ?
N DB ?
P DB ?
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS ,AX
MOV AH,01H ;INPUT
INT 21H
MOV N,AL
MOV AH,9 ;INPUT AFTER NEWLINE
LEA DX,NEWLINE
INT 21H
MOV I,'1'
LOOP1:
MOV AL,N ;P=N
MOV P,AL
MOV AL,I
MOV J,AL ;J=I
MOV AL,N
CMP I,AL
JLE LOOP2
INCRE1:
MOV AL,01H ;INCREAMENT
ADD I,AL
MOV AL,N
CMP I,AL
MOV AH,9 ;PRINT NEWLINE
LEA DX,NEWLINE
INT 21H
JG EXIT
JMP LOOP1
LOOP2:
MOV AL,N
CMP J,AL
JLE PRINTSTAR
INCRE2:
MOV AL,1
ADD J,AL
MOV AL,N
CMP J,AL
JG INCRE1
JMP LOOP2
PRINTSTAR:
MOV AH,2
MOV DL,P
INT 21H
MOV AL,01H
SUB P,AL
JMP INCRE2
EXIT:
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN
*******************************************************
Assignment-5
******************************************************
.MODEL SMALL
.STACK 100H
.DATA
CR EQU 0DH ;CARRIGE RETURN NEW LINE
LF EQU 0AH ;LINEFREED
MSG1 DB 'I AM AMIT$'
NEWLINE DB CR,LF ,'$'
I DB ?
J DB ?
K DB ?
L DB ?
N DB ?
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS ,AX
MOV AH,01H ;INPUT
INT 21H
MOV N,AL
MOV AH,9 ;INPUT AFTER NEWLINE
LEA DX,NEWLINE
INT 21H
MOV I,'1'
LOOP1: ;for(int i=1;i<=n;i++)
MOV AL,I ;J=I
MOV J,AL
MOV AL,'1' ;K=1
MOV K,AL
MOV L,AL ;L=1
MOV AL,N
CMP I,AL
JLE LOOP2
INCRE1:
MOV AL,01H ;INCREAMENT
ADD I,AL
MOV AL,N
CMP I,AL
MOV AH,9 ;PRINT NEWLINE
LEA DX,NEWLINE
INT 21H
JG EXIT
JMP LOOP1
LOOP2: ; for(int J=i;J<n;J++)
MOV AL,N
CMP J,AL
JL PRINTSPACE
INCRE2:
MOV AL,1
ADD J,AL
MOV AL,N
CMP J,AL
JGE LOOP3 ;;;;
JMP LOOP2
LOOP3: ;1 TO K<=I
MOV AL,I
CMP K,AL
JLE PRINTSTAR
INCRE3:
MOV AL,01H
ADD K,AL
MOV AL,I
CMP K,AL
JG LOOP4
JMP LOOP3
LOOP4: ;1 TO L<I
MOV AL,I
CMP L,AL
JL PRINTSTAR4
INCRE4:
MOV AL,01H
ADD L,AL
MOV AL,I
CMP L,AL
JGE INCRE1
JMP LOOP4
PRINTSPACE:
MOV AH,2
MOV DL,' '
INT 21H
JMP INCRE2
PRINTSTAR:
MOV AH,2
MOV DL,K
INT 21H
JMP INCRE3
PRINTSTAR4:
MOV AH,2
MOV AL,I
MOV BL,L
SUB BL,030H ; CHAR TO INT
SUB AL,BL
MOV DL,AL
INT 21H
JMP INCRE4
EXIT:
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN
0 comments :
Post a Comment