,,,
: , .
: 9- , . , (, ).
:
;----------- 3
.MODEL SMALL
.STACK 100H
.186
.DATA
S1 DB ' '
DB ' ( -48848 18806): ',10,13,'$'
S2 DB ' '
DB ' ( -48848 18806): ',10,13,'$'
S3 DB ' '
DB ' .','$'
S4 DB ' : .','$'
S5 DB ' : .','$'
S6 DB ': ',10,13,'$'
S7 DB ': ',10,13,'$'
L DB '48848' ;
H DB '108806' ;
SX DB 12 DUP('x') ;
SY DB 12 DUP('y') ;
SZ DB 8 DUP('0'),'$' ;
.CODE
BEGIN: MOV AX, @DATA
MOV DS, AX
;-----------
START: CLI ;
SUB AX, AX
MOV ES, AX
MOV AL, ES:[41AH]
MOV ES:[41CH], AL
STI ;
;-----------
CLD
MOV AX, 0B800H
MOV ES, AX
MOV DI, 0
MOV AL, 32
MOV AH, 7
MOV CX, 2000
REP STOSW
;-----------
MOV AH, 2 ;
MOV BH, 0 ;
MOV DH, 0 ;
MOV DL, 0 ;
INT 10H ;
;-----------
LEA DX, S1
MOV AH, 9
INT 21H
;-----------
LEA DX, SX
MOV BX, DX
MOV [BX], BYTE PTR 9 ;
MOV AH, 0AH
INT 21H
;-----------
MOV AH, 2 ;
MOV BH, 0 ;
MOV DH, 2 ;
MOV DL, 0 ;
INT 10H ;
;-----------
LEA DX, SX
MOV BX, DX
CALL CONTROL ;
MOV AL, [BX]
CMP AL, '0'
JE ZERO1 ;
JMP NEAR PTR DELITEL
ZERO1: LEA DX, S3
MOV AH, 9
INT 21H
;===========
MOV AH, 7
INT 21H
JMP NEAR PTR START
;-----------
DELITEL: LEA DX, S2
MOV AH, 9
INT 21H
;-----------
INPUT: LEA DX, SY
MOV BX, DX
MOV [BX], BYTE PTR 9 ;
MOV AH, 0AH
INT 21H
;-----------
MOV AH, 2 ;
MOV BH, 0 ;
MOV DH, 4 ;
MOV DL, 0 ;
INT 10H ;
;-----------
LEA DX, SY
MOV BX, DX
CALL CONTROL ;
CMP [BX], BYTE PTR '0'
JE ZERO2 ;
JMP NEAR PTR OK
ZERO2: LEA DX, S3
MOV AH, 9
INT 21H
;===========
MOV AH, 7
INT 21H
;-----------
CLI
SUB AX, AX
MOV ES, AX
MOV AL, ES:[41AH]
MOV ES:[41CH], AL
STI
;-----------
CLD
MOV AX, 0B800H
MOV ES, AX
MOV DI, 480
MOV AL, 32
MOV AH, 7
MOV CX, 480
REP STOSW
;-----------
MOV AH, 2 ;
MOV BH, 0 ;
MOV DH, 3 ;
MOV DL, 0 ;
INT 10H ;
JMP NEAR PTR INPUT
;-----------
OK: MOV AH, 2 ;
MOV BH, 0 ;
MOV DH, 4 ;
MOV DL, 0 ;
INT 10H ;
;-----------
LEA BX, SX
CALL CTRL0
MOV AH, [BX]
LEA BX, SY
CALL CTRL0
MOV AL, [BX]
CMP AL, '0'
JE NULL
JMP N_NULL
;-----------
NULL: LEA DX, S4
MOV AH, 9
INT 21H
JMP NEAR PTR ENDPROG
;-----------
N_NULL: CMP AH, '0'
JNE DELENIE
;-----------
LEA DX, S7
MOV AH, 9
INT 21H
LEA BX, SZ
MOV [BX], BYTE PTR '0'
INC BX
MOV [BX], BYTE PTR 10
INC BX
MOV [BX], BYTE PTR 13
INC BX
MOV [BX], BYTE PTR '$'
LEA DX, SZ
MOV AH, 9
INT 21H
LEA DX, S6
MOV AH, 9
INT 21H
LEA DX, SZ
MOV AH, 9
INT 21H
JMP NEAR PTR ENDPROG
;-----------
DELENIE: LEA SI, SX
LEA DI, SY
CALL COMPARE
CMP [SI], BYTE PTR 1
JE POSSIBLE
;-----------
LEA DX, S5
MOV AH, 9
INT 21H
JMP NEAR PTR ENDPROG
;-----------
POSSIBLE: MOV BX, 7 ;BX -
;----------- -
AGAIN: MOV CL, SY[1] ;CX -
MOV CH, 0
;-----------DI -
MOV DI, CX ;DI -
INC DI
;-----------
MOV SI, 2 ;SI -
MOV AL, SY[SI]
CMP AL, '-'
JNE BEFORE_C1
INC SI
DEC CX
BEFORE_C1: MOV AL, SY[SI]
CMP AL, '0'
JE SS1
JMP LBLL
SS1: INC SI
DEC CX
JMP BEFORE_C1
;-----------SI -
LBLL: MOV AL, SX[1]
CBW ; -
MOV SI, AX
INC SI
;-----------
;===========
C1: MOV AL, SX[SI]
CMP AL, SY[DI]
JAE NEXT
;===========
ADD AL, 9 ;
SUB AL, SY[DI] ;
ADD AL, '0' ;
SUB AL, AH ;
MOV SX[SI], AL ; -
MOV AH, 1 ;
JMP NEAR PTR DECREM ;
;===========
NEXT: SUB AL, SY[DI] ;
SUB AL, AH ;
MOV AH, 0 ;
ADD AL, '0' ;
MOV SX[SI], AL ; -
;-----------SI, DI -
DECREM: DEC SI
DEC DI
LOOP C1 ;
;-----------
CMP AH, 1
JNE SRAVN
;-----------
AGAIN1: CMP SX[SI], '0' ; ˨
JE C2
DEC SX[SI]
JMP SRAVN
;-----------
C2: MOV SX[SI], '8'
DEC SI ;
JMP AGAIN1 ; ˨
;===========
;-----------
SRAVN: CMP SZ[BX], '8'
JE PERENOS
;-----------
ADD SZ[BX], 1 ;
MOV BX, 7 ; -
JMP DEL ;
;-----------
PERENOS: MOV SZ[BX], '0' ; -
DEC BX ;
JMP SRAVN ; "8"
;===========
DEL: LEA SI, SX
LEA DI, SY
CALL COMPARE
MOV AL, [SI]
CMP AL, 1
JNE QUIT ;
JMP NEAR PTR AGAIN ;
;-----------
QUIT: MOV AH, SX[2]
MOV AL, SY[2]
;-----------
CMP AH, '-'
JE SX_
JMP N_SX_
;----------- -
SX_: CMP AH, AL ;
JE OUTP ;
;----------- -
;===========
SY_: MOV BX, 0
SRCH: CMP SZ[BX], '0'
JE DALEE
JMP STOP
DALEE: INC BX
JMP SRCH
;-----------
STOP: DEC BX
MOV SZ[BX], '-'
JMP OUTP ;
;-----------
N_SX_: CMP AL, '-' ; ?
JE SY_ ;
;-----------
;===========
;----------- ":"
OUTP: LEA DX, S6
MOV AH, 9
INT 21H
; 10, 13 "$"
MOV BH, 0
MOV BL, SX[1]
ADD BX, 2 ; -
MOV SX[BX], 10
INC BX
MOV SX[BX], 13
INC BX
MOV SX[BX], '$'
;-----------
MOV AH, '0'
LEA BX, SX ; -
INC BX
INC BX
MOV AL, [BX]
CMP AL, '-'
JE MN
JMP N_MN
MN: MOV AH, '-'
INC BX
N_MN: MOV AL, [BX]
CMP AL, '0'
JE EQ1
JMP NEQ1
EQ1: INC BX
JMP N_MN
NEQ1: MOV AL, [BX]
DEC BX
CMP AL, 10
JE N_NUL
MOV [BX], AH
CMP AH, '-'
JE EQQ
JMP NEQQ
EQQ: MOV DX, BX
JMP LBL
NEQQ: INC BX
MOV AL, [BX]
CMP AL, 10
JE NUL
JMP N_NUL
NUL: DEC BX
N_NUL: MOV DX, BX
LBL: MOV AH, 9
INT 21H
;===========
LEA DX, S7
MOV AH, 9
INT 21H
LEA BX, SZ
Q: MOV AL, [BX]
CMP AL, '0'
JE SM3
JMP OUTPUT
SM3: INC BX
JMP Q
OUTPUT: MOV DX, BX
MOV AH, 9
INT 21H
;-----------
ENDPROG: MOV AH, 4CH
INT 21H
;=========== CONTROL - ?
CONTROL PROC
PUSHA ;
MOV BX, DX
INC BX
MOV AL, [BX]
MOV AH, 0
MOV CX, AX
;----------- ?
CMP AL, 0
JE ERR1 ;
;-----------
CMP AL, 6
JA ERR1 ;
INC BX
MOV AH, [BX]
CMP AH, '-'
JE MINUS
JMP NEAR PTR FOR1
MINUS: INC BX ;
DEC CX
;----------- ?
FOR1: MOV AH, [BX]
CMP AH, '9'
JB N1
ERR1: JMP NEAR PTR ERROR ;
N1: CMP AH, '0'
JB ERR1 ;
INC BX
LOOP FOR1
MOV [BX], BYTE PTR '$' ;
CMP AL, 6
JNE RETURN ; 6
MOV BX, DX
INC BX
MOV AH, 0
MOV CX, AX
INC BX
MOV AH, [BX]
CMP AH, '-'
JE M1 ;
LEA DI, H ;
JMP FOR2
M1: INC BX
DEC CX
LEA DI, L
; ?
FOR2: MOV AH, [BX]
CMP AH, [DI]
JA ERROR ;
JB RETURN ;
INC BX
INC DI
LOOP FOR2
JMP RETURN
ERROR: MOV BX, DX
MOV [BX], BYTE PTR '0'
RETURN: POPA ;
RET
CONTROL ENDP
;=========== CTRL0 - ?
CTRL0 PROC
PUSHA
MOV SI, 1
MOV CL, [BX+SI]
MOV CH, 0
INC SI
MOV AL, [BX+SI]
CMP AL, '-'
JE MIN
JMP CYCLE
MIN: INC SI
DEC CX
CYCLE: MOV AL, [BX+SI]
CMP AL, '0'
JNE FINISH
INC SI
LOOP CYCLE
MOV SI, 0
MOV AL, '0'
MOV [BX+SI], AL
FINISH: POPA
RET
CTRL0 ENDP
;=========== COMPARE -
COMPARE PROC
PUSHA
INC SI
INC DI
MOV AH, [SI]
MOV AL, [DI]
INC SI
INC DI
CMP BYTE PTR [SI], '-'
JE NEGAT1
JMP POZIT1
NEGAT1: DEC AH
INC SI
POZIT1: CMP BYTE PTR [DI], '-'
JE NEGAT2
JMP POZIT2
NEGAT2: DEC AL
INC DI
POZIT2: MOV BL, [SI]
CMP BL, '0'
JE SM
JMP DI0
SM: INC SI
DEC AH
JMP POZIT2
DI0: MOV BL, [DI]
CMP BL, '0'
JE SM1
JMP SRAV1
SM1: INC DI
DEC AL
JMP DI0
SRAV1: CMP AH, AL
JA ABOVE
JB BELOW
JMP EQUAL
ABOVE: LEA SI, SX
MOV [SI], BYTE PTR 1
JMP NEAR PTR END1
BELOW: LEA SI, SX
MOV [SI], BYTE PTR -1
JMP NEAR PTR END1
EQUAL: MOV CL, AL
MOV CH, 0
FOR3: MOV AH, [SI]
CMP AH, [DI]
JA ABOVE
JB BELOW
INC SI
INC DI
LOOP FOR3
JMP ABOVE
END1: POPA
RET
COMPARE ENDP
END BEGIN
: , . : 9- ,
Copyright (c) 2025 Stud-Baza.ru , , , .