DSEG SEGMENT
 MESS DB 'NEPRAVILNO$'
DSEG ENDS
;
STACK SEGMENT
  DW 256 DUP(?)
STACK ENDS
;
CODS SEGMENT
      ASSUME SS:STACK,CS:CODS,DS:DSEG
   BEGIN:
   ; ochistka screena
 MOV BX, DSEG
    MOV DS, BX
      MOV AX, 0600H
      MOV BH, 07
      MOV CX, 0000
      MOV DX, 184FH
      INT 10H
; ystanovka na 0 poziciu    
   MOV AH, 02H
   MOV BH, 0
   MOV DH, 0
   MOV DL, 0
   INT 10H
MOV BX,0 ; shchetchik ctrok
 MOV CH, 0    ;shchetchik vvedenix digits
 MOV CL, 0    ;summa
; vvod dannix
 M:  MOV AH, 1
          INT 21H
 INC CH
 AND AL, 0FH
 CMP AL, 0DH
 JE L1
 CMP CH, 4
             JNE METKA ; esli ne 4 to summiruem & na M
 PUSH CX
 AND CL, 0FH
 MOV DL, CL
 POP CX
 AND CL, 0F0H
 MOV DH, CL
; ustanovka v nujnoe mesto                    
      MOV AH, 02H 
      INT 10H
 OR AL, 30H
 MOV DL, AL
; vivod simvola 
MOV AH, 2
 INT 21H
 MOV CL, 0
 MOV CH, 0               
 ; ustanovka vvodimix simvolov na next strochky gde bil vvod             
   INC BL
   MOV DX, 0
   MOV AH, 02H
   MOV BH, 0
   MOV DH, BL
   MOV DL, 0
   INT 10H
JMP M
  METKA: ADD CL, AL 
 JMP M
L1: CMP CH, 5 ; t. k. inc ran`she proverki
 JE M1
 ; vivod na next stroke
           MOV AH, 2
            MOV DL, 0AH
            INT 21H
            MOV AH, 2
            MOV DL, 0DH
            INT 21H
 MOV AH, 9
 MOV DX, OFFSET MESS
 INT 21H
 M1:
 MOV AX, 4C00H
 INT 21H
CODS ENDS
END BEGIN 