Monday, 6 July 2015

Binary Input And Binary Output Check illegal input Or Not In Assembly Language Solution.

/*Binary Input And Binary Output Check illegal input Or Not In Assembly Language Solution.*/

/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/

Solution:

.MODEL SMALL
.STACK 100H
.DATA
     STR DB 0AH,0DH,'Illegal Input. $'
.CODE

MAIN PROC
 
    MOV AX,@DATA
    MOV DS,AX
 
    MOV BX,0
    MOV CL,1
 
    TOP:
       MOV AH,1
       INT 21H
       CMP AL,0DH
       JE END_
     
       CMP AL,30H
       JNE CHECK

       CONTINUE:
           SUB AL,30H
         
           SHL BX,CL
           OR BL,AL

       JMP TOP
    CHECK:
        CMP AL,31H
        JNE MSG
        JMP CONTINUE
    END_:  
 
    MOV AH,2
    MOV DL,0AH
    INT 21H
    MOV DL,0DH
    INT 21H
 
    MOV CL,1
    MOV CH,0
    OUTPUT:
          CMP CH,16
          JE FINISH
          INC CH
          SHL BX,CL
          JC ONE
       
       
          MOV AH,2
          MOV DL,30H
          INT 21H
          JMP OUTPUT
       
    ONE:
        MOV AH,2
        MOV DL,31H
        INT 21H
        JMP OUTPUT
    MSG:
        MOV AH,9
        LEA DX,STR
        INT 21H
     
    FINISH:  
    MOV AH,4CH
    INT 21H
           
   
    MAIN ENDP
END MAIN

No comments:

Post a Comment