(49533)

: , .

: 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






- .
, VIP-.
. .