Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model small
- data segment
- msg_a db 13,10, "a = ", '$'
- msg_b db 13,10, "b = ", '$'
- msg_c db 13,10, "c = ", '$'
- msg_d db 13,10, "d = ", '$'
- msg_result db 13,10, "a*c*(a+b)-d = ", '$'
- a db ?
- b db ?
- c db ?
- d dw ?
- result dw ?
- data ends
- stk segment stack
- db 256 dup(?)
- stk ends
- code segment
- assume cs: code, ds: data, ss: stk
- start:
- mov ax, data
- mov ds, ax
- Vvod_peremenou:
- mov ah, 09h
- lea dx, [msg_d]
- int 21h
- mov di, offset store_D
- jmp ReadInt16
- store_D:
- mov [d], ax
- mov ah, 09h
- lea dx, [msg_a]
- int 21h
- mov di, offset store_A
- jmp ReadInt16
- store_A:
- mov [a], al
- mov ah, 09h
- lea dx, [msg_b]
- int 21h
- mov di, offset store_B
- jmp ReadInt16
- store_B:
- mov [b], al
- mov ah, 09h
- lea dx, [msg_c]
- int 21h
- mov di, offset store_C
- jmp ReadInt16
- store_C:
- mov [c], al
- Vichislenia:
- mov al,[a]
- imul [c]
- mov bx, ax
- mov al,[a]
- add al,[b]
- cbw
- imul bx
- sub ax,[d]
- mov [result], ax
- Vivod_resultata:
- mov ah, 09h
- lea dx, [msg_result]
- int 21h
- mov ax, [result]
- Vivod_result:
- mov bx, 10
- xor cx, cx
- or ax, ax
- jns _div
- neg ax
- push ax
- mov ah, 02h
- mov dl, '-'
- int 21h
- pop ax
- _div:
- xor dx, dx
- div bx
- push dx
- inc cx
- or ax, ax
- jnz _div
- mov ah, 02h
- store:
- pop dx
- add dl, '0'
- int 21h
- loop store
- ReadInt16:
- xor bx, bx
- xor cx, cx
- do:
- mov ah, 00h
- int 16h
- mov dl, al
- cmp al, 0Dh
- je _break
- cmp al, '-'
- jne plyc
- mov bx, 1
- cmp bx,1
- je putchar
- plyc:
- cmp al,'+'
- jne @endif
- mov bx,0
- je putchar
- @endif:
- sub al, '0'
- jc do
- cmp al, 9+1
- jnc do
- xor ah, ah
- shl cx, 1
- mov si, cx
- shl cx, 1
- shl cx, 1
- add cx, si
- add cx, ax
- putchar:
- mov ah, 02h
- int 21h
- jmp do
- _break:
- mov ax, cx
- test bx, bx
- jz exit
- neg ax
- exit:
- jmp di
- the_end:
- mov ax, 4C00h
- code ends
- end start
Advertisement
Add Comment
Please, Sign In to add comment