Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data segment
- a dw ?
- nmb db ?
- answer dw 0h
- result dw 0h
- ax_temp dw ?
- bx_temp dw ?
- temp db ?
- 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:
- mov ax_temp, ax
- add di, 2
- mov ax, 0730h
- add al, nmb
- mov es:[di], ax
- mov ax, ax_temp
- ret
- start: mov cx, 0Ah
- inloop: in al, 60h
- cmp al, bl
- je inloop
- mov bl, al
- cmp al, 01h
- jne isEnter
- jmp quit
- isEnter:cmp al, 1Ch
- jne NotEsc
- ret
- 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 ax, 0
- mov bl, 0Ah
- mov ax, answer
- mul bl
- add ax, a
- mov answer, ax
- 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
- mov ax, answer
- mov result, ax
- mov answer, 0h
- add di, 2
- call start
- mov es:[di], 073Dh ; 3D - ascii =;
- mov ax, result
- add ax, answer
- cmp ax, 0
- jge ns
- dec ax
- not ax
- add di, 2
- mov es:[di], 072Dh ; 2D - ascii -;
- ns: mov bl, 0Ah
- div bl ; Get div of number;
- cmp al, 0Ah
- jl num2
- mov temp, ah
- mov ah, 0
- div bl
- mov nmb, al
- call outp_n
- mov al, ah
- mov ah, temp
- num2: 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