Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data segment
- a dw ?
- b dw 9
- nmb db ?
- pnt dw 0h
- answer db 0h
- tt_d db 0h
- ax_temp dw ?
- bx_temp dw ?
- data ends
- code segment
- assume cs:code, ds:data
- main: mov dx, data
- mov ds, dx
- mov dx, 0B800h
- mov es, dx
- xor di, di
- xor dx, dx ; Clear display
- mov ax, 0720h
- mov cx, 80*25
- rep stosw
- jmp gen
- outp_n:
- mov di, 80*4
- mov ax, 0730h
- add al, nmb
- add di, pnt
- mov es:[di], ax
- ret
- start: mov cx, 02h
- inloop: in al, 60h
- cmp al, bl
- je inloop
- mov bl, al
- cmp al, 01h
- jne NotEsc
- jmp quit
- NotEsc: cmp al, 0Bh
- jne CkInNum
- mov a, 0
- mov es:[di], 0730h
- jmp NxtNum
- CkInNum:cmp al, 02h ; check scancode in range
- jl Not9
- cmp al, 0Ah
- jg Not9
- mov ah, 0h
- mov si, ax
- dec si
- mov a, si
- add si, 0730h
- mov es:[di], si
- jmp NxtNum
- Not9: jmp inloop
- NxtNum:
- mov ax_temp, ax ; Answer
- mov bx_temp, bx
- mov bl, 0Ah
- mov al, answer
- mul bl
- add ax, a
- mov answer, al
- mov ax, ax_temp
- mov bx, bx_temp
- inc di
- inc di
- dec cx
- jnz Not9
- mov ax, 0h
- ret
- gen:
- mov di, 0 ; Input 2 numbers
- call start
- mov al, tt_d
- add al, answer
- mov tt_d, al
- mov answer, 0h
- mov di, 80*2
- call start
- mov al, tt_d
- add al, answer
- mov bl, 0Ah
- div bl ; Get div of number
- mov nmb, al ; Number output
- mov bl, ah
- call outp_n
- add pnt, 2
- mov nmb, bl
- call outp_n
- pause: in al, 60h
- cmp al, 01h
- jne pause
- quit: mov ax, 4C00h
- int 21h
- code ends
- end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement