Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .386
- ASSUME CS: CODE, DS: DATA
- DATA SEGMENT USE16 PUBLIC
- STRING1 DB 100, 99 DUP ('$')
- STRING2 DB 100, 99 DUP ('$')
- HELP DB 100, 99 DUP ('$')
- DUMMY DB 0AH, '$'
- RESULT DB 100 DUP ('$')
- SUM DB 100 DUP ('$')
- OVERFLOW DB ?
- END1 DB ?
- END2 DB ?
- ONE DB ?
- TWO DB ?
- IS DB ?
- GREAT DB ?
- MINUS DB ?
- COUNT DW ?
- TEN DB 10
- NUMOFSTEP DW ?
- C1 DW ?
- C2 DW ?
- M1 DB ?
- M2 DB ?
- CURMINUS DB ?
- CURSTEP DB ?
- LEN DW ?
- MORE DW ?
- DATA ENDS
- CODE SEGMENT USE16 PUBLIC
- CLEAR1 PROC
- MOV STRING1[SI], '$'
- INC SI
- CMP SI, 99
- JNE CLEAR1
- RET
- CLEAR1 ENDP
- CLEAR2 PROC
- MOV STRING2[SI], '$'
- INC SI
- CMP SI, 99
- JNE CLEAR2
- RET
- CLEAR2 ENDP
- SCAN1 PROC
- mov dx, offset string1
- mov ax, 0
- mov ah, 0Ah
- int 21h
- mov dx, offset dummy
- mov ah, 09h
- int 21h
- mov dx, offset string1
- RET
- SCAN1 ENDP
- SCAN2 PROC
- mov dx, offset string2
- mov ax, 0
- mov ah, 0Ah
- int 21h
- mov dx, offset dummy
- mov ah, 09h
- int 21h
- mov dx, offset string2
- RET
- SCAN2 ENDP
- ADDZERO PROC
- CMP C2, 0
- JE AZ
- MOV RESULT[BX], 0
- INC BX
- DEC C2
- CALL ADDZERO
- ADDZERO ENDP
- MOSN PROC
- MOV BX, NUMOFSTEP
- MOV C2, BX
- MOV BX, 0
- CALL ADDZERO
- AZ:
- MOV AX, 2
- ADD AX, MORE
- CMP DI, AX
- JL EXML
- MOV SI, COUNT
- MOV AL, STRING2[DI]
- MOV TWO, AL
- SUB TWO, 48
- MOV OVERFLOW, 0
- JMP STEP
- STE:
- MOV BX, 0
- MOV SI, 0
- MOV C1, 0
- MOV END1, 0
- MOV END2, 0
- MOV OVERFLOW, 0
- CALL MULSUM
- MS:
- INC NUMOFSTEP
- DEC DI
- CALL MOSN
- MOSN ENDP
- ADDSM PROC
- CMP OVERFLOW, 0
- JNE ADDDIGIT
- AD:
- JMP STE
- ADDSM ENDP
- ADDDIGIT PROC
- MOV AL, OVERFLOW
- MOV RESULT[BX], AL
- INC BX
- JMP AD
- ADDDIGIT ENDP
- STEP PROC
- MOV AX, 2
- ADD AX, MORE
- CMP SI, AX
- JL ADDSM
- MOV AL, STRING1[SI]
- SUB AL, 48
- MUL TWO
- ADD AL, OVERFLOW
- MOV OVERFLOW, 0
- MOV ONE, AL
- CMP ONE, 10
- JAE OVERM
- OVM:
- MOV AL, ONE
- MOV RESULT[BX], AL
- INC BX
- DEC SI
- CALL STEP
- STEP ENDP
- OVERM PROC
- MOV AL, ONE
- XOR AH, AH
- DIV TEN
- MOV OVERFLOW, AL
- MOV ONE, AH
- JMP OVM
- OVERM ENDP
- SET0LSM PROC
- MOV AL, 0
- MOV END1, 1
- JMP SLSM
- SET0LSM ENDP
- SET0HSM PROC
- MOV AL, 0
- MOV END2, 1
- JMP SHSM
- SET0HSM ENDP
- OVERSM PROC
- MOV OVERFLOW, 1
- SUB ONE, 10
- JMP OVSM
- OVERSM ENDP
- RETSM PROC
- CMP OVERFLOW, 1
- JE ADD1SM
- A1SM:
- MOV BX, 0
- CALL CHANGESM
- RM:
- MOV BX, 0
- JMP MS
- RETSM ENDP
- ADD1SM PROC
- MOV HELP[BX], 1
- INC BX
- JMP A1SM
- ADD1SM ENDP
- CHANGESM PROC
- MOV AL, HELP[BX]
- CMP AL, '$'
- JE RM
- MOV SUM[BX], AL
- INC BX
- CALL CHANGESM
- CHANGESM ENDP
- MULSUM PROC
- MOV AL, SUM[SI]
- CMP AL, '$'
- JE SET0LSM
- SLSM:
- MOV ONE, AL
- MOV AL, RESULT[BX]
- CMP AL, '$'
- JE SET0HSM
- SHSM:
- MOV TWO, AL
- MOV AL, END1
- ADD AL, END2
- CMP AL, 2
- JE RETSM
- MOV AL, ONE
- ADD AL, TWO
- ADD AL, OVERFLOW
- MOV OVERFLOW, 0
- MOV ONE, AL
- CMP ONE, 10
- JAE OVERSM
- OVSM:
- MOV AL, ONE
- MOV C2, BX
- MOV BX, C1
- MOV HELP[BX], AL
- MOV BX, C2
- INC BX
- INC SI
- INC C1
- CALL MULSUM
- MULSUM ENDP
- ;----------------------------------------
- SETMINUS PROC
- MOV MINUS, 1
- MOV MORE, 1
- JMP SM
- SETMINUS ENDP
- COPY PROC
- CMP SI, 0
- JL CP
- MOV AL, STRING1[SI]
- MOV STRING2[SI], AL
- DEC SI
- CALL COPY
- COPY ENDP
- EOFN PROC
- CMP GREAT, 0
- JE PRINTEM
- MOV AL, 1
- XOR CURMINUS, AL
- MOV SI, 2
- ADD SI, MORE
- CMP CURSTEP, 0
- JE SETSICOUNT
- JNE SETSI
- SSC:
- MOV DI, LEN
- MOV END1, 0
- MOV END2, 0
- MOV NUMOFSTEP, 0
- CALL MOSN
- EXML:
- MOV SI, 0
- CALL MSTS
- MSTS1:
- DEC SI
- MOV DI, 2
- ADD DI, MORE
- CALL COPYSUM
- CS1:
- SUB DI, 2
- MOV AX, DI
- MOV SI, 1
- MOV STRING1[SI], AL
- MOV SI, 0
- CALL CLEARSUM
- CCC:
- DEC GREAT
- INC CURSTEP
- CALL EOFN
- EOFN ENDP
- CLEARSUM PROC
- MOV AL, SUM[SI]
- CMP AL, '$'
- JE CCC
- MOV AL, '$'
- MOV SUM[SI], AL
- INC SI
- CALL CLEARSUM
- CLEARSUM ENDP
- COPYSUM PROC
- CMP SI, 0
- JL CS1
- MOV AL, SUM[SI]
- ADD AL, 48
- MOV STRING1[DI], AL
- INC DI
- DEC SI
- CALL COPYSUM
- COPYSUM ENDP
- SETSICOUNT PROC
- MOV SI, LEN
- MOV COUNT, SI
- JMP SSC
- SETSICOUNT ENDP
- SETSI PROC
- MOV AL, STRING1[SI]
- CMP AL, '$'
- JE SETCOUNT
- INC SI
- CALL SETSI
- SETSI ENDP
- SETCOUNT PROC
- DEC SI
- MOV COUNT, SI
- JMP SSC
- SETCOUNT ENDP
- MSTS PROC
- MOV AL, SUM[SI]
- CMP AL, '$'
- JE MSTS1
- INC SI
- CALL MSTS
- MSTS ENDP
- PRINTEM PROC
- CMP CURMINUS, 1
- JE PM
- PMM:
- MOV BX, 2
- ADD BX, MORE
- CALL SHOWME
- PRINTEM ENDP
- PM PROC
- CMP MINUS, 1
- JNE PMM
- MOV AH, 02H
- MOV DL, 45
- INT 21H
- JMP PMM
- PM ENDP
- SHOWME PROC
- MOV AL, STRING1[BX]
- CMP AL, '$'
- JE RETURN6
- MOV DL, AL
- MOV AH, 02H
- INT 21H
- INC BX
- CALL SHOWME
- SHOWME ENDP
- FAST1 PROC
- MOV DX, OFFSET STRING1
- ADD DX, 2
- MOV AH, 09H
- INT 21H
- JMP RETURN6
- FAST1 ENDP
- START:
- MOV AX, DATA
- MOV DS, AX
- ;-------EXPONENTIATION OF SIGNED NUMBERS--------
- CALL SCAN1
- CALL SCAN2
- MOV MORE, 0
- MOV MINUS, 0
- MOV SI, 2
- MOV AL, STRING1[SI]
- CMP AL, 45
- JE SETMINUS
- SM:
- MOV AL, MINUS
- MOV CURMINUS, AL
- MOV SI, 1
- MOV BL, STRING1[SI]
- XOR BH, BH
- MOV SI, BX
- ADD SI, 1
- MOV COUNT, SI
- MOV LEN, SI
- MOV DI, 2
- MOV AL, STRING2[DI]
- DEC AL
- SUB AL, 48
- MOV GREAT, AL
- CMP GREAT, 0
- JE FAST1
- MOV SI, COUNT
- CALL COPY
- CP:
- MOV CURSTEP, 0
- MOV AL, MINUS
- MOV M1, AL
- MOV M2, 0
- CALL EOFN
- RETURN6:
- MOV AH, 02H
- MOV DL, 10
- INT 21H
- MOV AH, 02H
- MOV DL, 13
- INT 21H
- ;-----------------------------------------
- MOV AH, 4CH
- INT 21H
- CODE ENDS
- END START
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement