For some reason, when I switch to mouse input switch back to keyboard input for my program, increasing and decreasing the counter has no effect. It works perfectly in the first loop where we input characters. Here is the program, any advice? Look at whatspeed jump for reference after mousetime jump. CX counter is not updating or something along those lines. (I do not know if the counter is not updating or weather there is a problem occuring in comparing CX after I switch from mousetime to keytime . )
    CLEAR   MACRO
    MOV AX,0600H
    MOV BH,07
    MOV CX,0000
    MOV DX,184FH
    INT 10H
  ENDM  
CURSOR  MACRO Col, Row
    MOV AH,02
    MOV BH,00
    MOV DL,Col
    MOV DH,Row
    INT 10H
  ENDM
DISP   MACRO MES
    MOV AH,09
    MOV DX,OFFSET MES
    INT 21H
ENDM
CLEARLINE MACRO ROW
    CURSOR 00,ROW
    DISP SPACES
    ENDM
ALWAYSONSCREENINFO MACRO
        CURSOR 16,00
        DISP TITLE1
        CURSOR 50,00
        DISP NAMES1 
        CURSOR 54,01
        DISP NAMES2
        CURSOR 33,7
        DISP MENU
        CURSOR 24,9
        DISP OPTION1
        CURSOR 24,10
        DISP OPTION2
        CURSOR 22,11
        DISP DASHES
        CURSOR 18,12
        DISP MOUSEMENU
        CURSOR 14,13
        DISP OPTION3
        CURSOR 8,14
        DISP OPTION4
        CURSOR 13,15
        DISP CHARMENU
        CURSOR 21,16
        DISP KILL
ENDM
.MODEL SMALL ; RUN THE PROGRAM IN DIMENSIONS 79x24 
.STACK 64H
.DATA
TITLE1          DB      'MICROPROCESSOR - EENG410','$'
NAMES1          DB      'name1 & name2','$'
NAMES2          DB      'std1         std2','$'
MENU            DB      'MENU','$'
OPTION1         DB      '1. Press "U" to Speed up the motor','$'
OPTION2         DB      '2. Press "D" to Slow Down the motor','$'
OPTION3         DB      '1. Right click the mouse to turn motor direction to clockwise','$'
OPTION4         DB      '2. Left click the mouse to turn the motor direction to anti-clockwise','$'
DASHES          DB      '----------------------------------------','$'
MOUSEMENU       DB      '(Press M to switch to the mouse options)','$'
CHARMENU        DB      '(Press the scroll button to switch back to fist 2 options)','$' 
SPEEDUP         DB      'DC motor is speeding up ','$'
SLOWDOWN        DB      'DC motor is slowing down','$'
RIGHT           DB      'DC motor will now rotate clockwise','$'
LEFT            DB      'DC motor will now rotate anti-clockwise','$'
KILL            DB      '-----To exit the program, press "E"-----','$'
PROGRAMEND1     DB      'Thank you for using our program','$'
PROGRAMEND2     DB      'The program has been terminated','$'
SPACES          DB      '                                                                                    ','$'
TRY             DB      'Please try again','$'
SPEEDNOW        DB      'Speed:','$'
DIRECTION       DB      'Motor Direction:','$'
CLOCK           DB      'Right','$'
COUNTER         DB      'Left  ','$'
N1              DB      '1','$'  
N2              DB      '2','$'
N3              DB      '3','$'
N4              DB      '4','$'
N5              DB      '5','$'
N6              DB      '6','$'
N7              DB      '7','$'
MAXSPEED        DB      'Max speed is 7','$'
MINSPEED        DB      'Min speed is 1','$'  
.CODE
MAIN:   MOV AX,@DATA
        MOV DS, AX
        CLEAR
        ALWAYSONSCREENINFO
        MOV CX,1
        CURSOR 28,21
        DISP SPEEDNOW
        CURSOR 35,21
        DISP N1
        CURSOR 22,22
        DISP DIRECTION
        CURSOR 39,22
        DISP CLOCK
        MOV CX,1
L0:     MOV AH,00   ;LOOP START
        INT 16H
        CMP AL,' '
        JE SPACED
        CMP AL,'U'
        JE FASTER
        CMP AL,'u'
        JE FASTER
        CMP AL,'D'
        JE SLOWER
        CMP AL,'d'
        JE SLOWER
        CMP AL,'M'
        JE MOUSETIME
        CMP AL,'m'
        JE MOUSETIME
        CMP AL,'E'
        JE EXIT
        CMP AL,'e'
        JE EXIT
        JNE TRYAGAINKEY
A1:     MOV AX,03
        INT 33H
        CMP BX,0
        JE A1
        CMP BX,1    ;MOUSE LEFT
        JE MRIGHT
        CMP BX,2    ;MOUSE RIGHT
        JE MLEFT
        CMP BX,3
        JE KEYTIME
SPACED: CLEARLINE 19
        JMP L0
FASTER: CLEARLINE 19
        CURSOR 27,19
        DISP SPEEDUP
        JMP INCREASE
SLOWER: CLEARLINE 19
        CURSOR 27,19
        DISP SLOWDOWN
        JMP DECREASE
MOUSETIME:  JMP A1
KEYTIME:    JMP L0
MRIGHT: CLEARLINE 19
        CURSOR 18,19
        DISP RIGHT
        JMP TRIGHT
MLEFT:  CLEARLINE 19
        CURSOR 18,19
        DISP LEFT
        JMP TLEFT
TRYAGAINKEY:    CLEARLINE 19
                CURSOR 28,19
                DISP TRY
                JMP L0 
INCREASE: CMP CX,7
          JE CANNOTINCREASESPEED
          INC CX
          JMP WHATSPEED
DECREASE: CMP CX,1
          JE CANNOTDECREASESPEED
          DEC CX
          JMP WHATSPEED
TRIGHT: CURSOR 39,22
        DISP CLOCK
        JMP A1
TLEFT:  CURSOR 39,22
        DISP COUNTER
        JMP A1
CANNOTINCREASESPEED:    CLEARLINE 19
                        CURSOR 27,19
                        DISP MAXSPEED
                        JMP L0
CANNOTDECREASESPEED:    CLEARLINE 19
                        CURSOR 27,19
                        DISP MINSPEED
                        JMP L0
WHATSPEED:  CMP CX,1
            JE N11
            CMP CX,2
            JE N22
            CMP CX,3
            JE N33
            CMP CX,4
            JE N44
            CMP CX,5
            JE N55
            CMP CX,6
            JE N66
            CMP CX,7
            JE N77
N11:    CURSOR 35,21
        DISP N1
        JMP L0
N22:    CURSOR 35,21
        DISP N2
        JMP L0
N33:    CURSOR 35,21
        DISP N3
        JMP L0
N44:    CURSOR 35,21
        DISP N4
        JMP L0
N55:    CURSOR 35,21
        DISP N5
        JMP L0
N66:    CURSOR 35,21
        DISP N6
        JMP L0
N77:    CURSOR 35,21
        DISP N7
        JMP L0
EXIT:   CLEAR
        CURSOR 21,12
        DISP PROGRAMEND1
        CURSOR 21,13
        DISP PROGRAMEND2
        MOV AH, 4CH
        INT 21H
    END MAIN
 
                        
The fault is caused because the mouse interrupt
33hfunctionAX=0003hreturns the mouse position inCXandDX.This overwrites your "counter" in register
CX.It is always a dangerous game to keep values in registers throughout a program. Better to have a memory variable location.
You could also try
PUSH CXbefore executing the mouse functions andPOP CXafter, but your program structure and flow might not be conducive to that (I have not followed it fully).Also, the reason why your program does not recover from (in your context) the absurd value of
CXis because of the test instruction you used. For example hereyou must always be cautious and trap any value that is out of range (even if you think it won't be)
Also with