Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- format MZ
- entry Main: Start
- segment Main
- Start:
- mov ax, WorkData
- mov ds, ax
- call far API: GetProccessedNum
- mov [X],dx
- call far API: GetProccessedNum
- mov [Y],dx
- call far API: CalculateResult ;result in dx
- mov dx, ax
- call far API: OutputSoughtNumber
- call far API: WaitForClick
- segment API
- CalculateResult:
- ; push ds
- mov ax, WorkData
- mov ds, ax
- mov ax,[X]
- mov si, 10
- mul si
- mov si, ax
- mov ax, [Y]
- mul ax
- mov cx, 6
- mul cx
- xor ax, si
- ;pop ds
- retf
- GetProccessedNum: ; Result in DX
- push ax
- mov ax, WorkData
- mov ds, ax
- mov ah, 0ah
- mov dx, input
- int 21h
- mov dh, [input + 1]
- mov [realSize], dh
- call ProccessNum
- call SetNewLine
- pop ax
- retf
- ProccessNum: ; Result in DX
- push cx
- push bx
- xor dx, dx
- mov ax, 1
- mov ch, 10
- movzx si, [realSize]
- LoopDigit:
- xor bx, bx
- mov bl, [input + si + 1]
- sub bl, '0'
- mov cl, al
- mul bl
- add dx, ax
- mov al, cl
- mul ch
- dec si
- test si,si
- jnz LoopDigit
- pop bx
- pop cx
- ret
- SetNewLine:
- push ax
- push dx
- mov ah, 09h
- mov dx, newLine
- int 21h
- pop dx
- pop ax
- ret
- OutputSoughtNumber: ;waits for dx
- mov ax, WorkData
- mov ds, ax
- mov [toOutput],dx
- mov bh, 10
- xor ax, ax
- mov ax, [toOutput]
- test ax, ax
- jz NumIsZero
- mov cx, 0
- DivideNum:
- add cx, 1
- div bh
- xor dx, dx
- mov dl, ah
- push dx
- xor ah, ah
- test ax, ax
- jnz DivideNum
- jmp OutputDigit
- NumIsZero:
- push 0
- mov cx, 1
- OutputDigit:
- pop dx
- add dx, 30h
- mov ah, 02h
- int 21h
- loop OutputDigit
- retf ;OutputSoughtNumber ret
- WaitForClick:
- push ax
- mov ah, 08h
- int 21h
- pop ax
- retf
- Segment WorkData
- input db 4,5 dup(?)
- newLine db 13,10,'$'
- realSize db ?
- toOutput dw ?
- X dw ?
- Y dw ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement