Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- assume cs: code, ds: data
- data segment
- dummy db 0Ah, '$'
- aLen db ?
- bLen db ?
- cLen db ?
- msg1Num db 'Enter first number line:', 10, 13, '$'
- msg2Num db 'Enter second number line:', 10, 13, '$'
- msgRes db 'Result:', 10, 13, '$'
- tab db 10, 13, '$'
- a db 40, 40 dup(0)
- b db 40, 40 dup(0)
- c db 40, 40 dup(0)
- data ends
- code segment
- read proc
- push bp
- mov bp, sp
- mov ah,0ah
- mov dx, [bp+4]
- int 21h
- pop bp
- ret 2
- read endp
- print proc
- push bp
- mov bp, sp
- mov ah,09h
- mov dx, [bp+4]
- int 21h
- pop bp
- ret 2
- print endp
- addInt proc
- push bp
- mov bp, sp
- mov bx, [bp+4]
- mov cl, byte ptr [bx+1] ; len(b)
- mov bLen, cl
- xor ax, ax
- mov dx, [bp+6]
- mov si, [bp+6]
- mov al, byte ptr [si+1] ; len(a)
- mov aLen, al
- cmp al, cl ; bx = b ; dx = a = si
- jle a1
- mov dx, bx
- mov bx, si
- a1:
- mov cl, bLen
- inc cl
- mov cLen, cl
- mov di, [bp+8]
- mov byte ptr [di+1], cl ; cLen
- mov byte ptr [di+2], '0' ; cLen
- mov cl, bLen
- mov si, bx
- mov cl, byte ptr [si+1]
- add si, 2
- add di, 3
- rep movsb
- mov byte ptr [di], '$'
- dec di ; last digit 'c'
- mov si, dx ; a
- mov cl, aLen
- inc cl
- add si, cx
- dec cl
- mov ch, cLen
- xor dx, dx
- std
- sum:
- mov bl, byte ptr [di]
- sub bl, 30h ;
- add bl, byte ptr [si]
- cycle:sub bl, 30h ; temp sum
- cmp dl, 1
- je one
- ret1: cmp bl, 9h
- jg rem
- ret2: add bl, 30h
- mov byte ptr [di], bl
- dec si
- dec di
- dec cl
- dec ch
- cmp cl, 0
- jg sum
- cmp ch, 0
- jg more
- cmp dl, 1
- je last
- ret3: jmp endd
- more:
- mov bl, byte ptr [di]
- jmp cycle
- last: mov dl, 0
- add byte ptr [di], 1h
- jmp ret3
- rem: mov dl, 1
- sub bl, 0ah
- jmp ret2
- one: inc bl
- mov dl, 0
- jmp ret1
- endd:
- pop bp
- pop bx
- push ax
- push offset c ;;;;;;;;; return
- push bx
- ret
- addInt endp
- start: mov ax, data
- mov ds, ax
- mov es, ax
- push offset msg1Num
- call print
- push offset a
- call read
- push offset tab
- call print
- push offset msg2Num
- call print
- push offset b
- call read
- push offset tab
- call print
- push offset msgRes
- call print
- push offset c ; +8
- push offset a ; +6
- push offset b ; +4
- call addInt
- pop dx
- add dx, 2
- push dx
- call print
- mov ah, 4ch
- int 21h
- code ends
- end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement