Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data segment
- a dw ?
- nmb db ?
- answer db 0h
- result 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 ; Base of videomemory;
- mov es, dx
- xor di, di
- xor dx, dx ; Clear display;
- mov ax, 0720h
- mov cx, 80*25
- rep stosw
- jmp gen
- outp_n:
- add di, 2
- mov ax, 0730h
- add al, nmb
- 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 es:[di], 072Bh ; 2B - ascii +;
- mov al, result
- add al, answer
- mov result, al
- mov answer, 0h
- add di, 2
- call start
- mov es:[di], 073Dh ; 3D - ascii =;
- mov al, result
- add al, answer
- mov bl, 0Ah
- div bl ; Get div of number;
- mov nmb, al ; Number output;
- mov bl, ah
- call outp_n
- 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