Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model small
- .stack 100h
- data segment ;??????? ??????
- msg_first db 13,10,'Enter number of elements: $'
- msg_second db 13,10,'Enter number: $'
- msg_plus db ', $'
- msg_mod db 13,10,'Result module: $'
- msg_mul db 13,10,'Result invers: $'
- msg_div db 13,10,'Result div: $'
- msg_no_div db 13,10,'Cant div$'
- msg_sqr db 13,10,'Result sqr: $'
- msg_div_al db 13,10,'Whole part: $'
- msg_div_ah db 13,10,'Surplus: $'
- n dw 1 dup(?)
- b db 10 dup('$') ;second number
- c dw 10 dup('$') ;result
- buff db 10 dup('$')
- buff1 db 10 dup('$')
- d db 10 dup('$')
- data ends
- code segment ;??????? ????
- assume cs:code,ds:data ;??????? ??? code, data ?????????? ??? ? ??????
- start:
- mov ax, 3 ;clear screen
- int 10h
- mov ax, data ;??? ???? ????? ??????? ?????? ? ds(??????? ??????) ??????? ??????? ? ax
- mov ds, ax
- lea dx, msg_first
- lea bx, buff
- lea cx, n
- CALL _input
- xor si, si
- enter_array:
- cmp si, n
- je op_preinv
- lea cx, b[si]
- lea dx, msg_second
- lea bx, buff1
- CALL _input
- CALL _fillcharbuff1
- inc si
- jmp enter_array
- op_preinv:
- xor si, si
- lea dx, msg_mul
- mov ah, 9
- int 21h
- CALL _fillchar
- op_inv:
- cmp si, n
- je op_premod
- xor ah, ah
- mov al, b[si]
- cmp b[si], 0
- jns posit
- mov ah, 1
- neg ah
- posit:
- neg ax
- CALL _fillcharc
- mov c, ax
- CALL _write
- lea dx, msg_plus
- mov ah, 9
- int 21h
- inc si
- jmp op_inv
- op_premod:
- xor si, si
- lea dx, msg_mod
- mov ah, 9
- int 21h
- CALL _fillchar
- op_mod:
- cmp si, n
- je op_presqr
- xor ah, ah
- mov al, b[si]
- cmp al, 0
- jns mod_cont
- cmp b[si], 0
- jns posit1
- mov ah, 1
- neg ah
- posit1:
- neg ax
- mod_cont:
- CALL _fillcharc
- mov c, ax
- CALL _write
- lea dx, msg_plus
- mov ah, 9
- int 21h
- inc si
- jmp op_mod
- op_presqr:
- xor si, si
- lea dx, msg_sqr
- mov ah, 9
- int 21h
- CALL _fillchar
- op_sqr:
- cmp si, n
- je op_prediv
- mov al, b[si]
- mov ah, b[si]
- imul ah
- CALL _fillcharc
- mov c, ax
- CALL _write
- lea dx, msg_plus
- mov ah, 9
- int 21h
- inc si
- jmp op_sqr
- op_prediv:
- xor si, si
- lea dx, msg_div
- mov ah, 9
- int 21h
- op_div:
- cmp si, n
- je @@_exit
- mov ax, 1
- mov bl, b[si]
- cmp bx, 0
- je op_no_div
- idiv bl
- CALL _fillcharc
- push ax
- lea dx, msg_div_al
- mov ah, 9
- int 21h
- pop ax
- push ax
- mov ah, 0
- cmp b[si], 0
- jns op_div_cont
- mov ah, 1
- neg ah
- op_div_cont:
- mov c, ax
- CALL _fillchar
- CALL _write
- lea dx, msg_div_ah
- mov ah, 9
- int 21h
- pop ax
- mov al, ah
- mov ah, 0
- mov c, ax
- CALL _fillchar
- CALL _write
- lea dx, msg_plus
- mov ah, 9
- int 21h
- inc si
- jmp op_div
- op_no_div:
- lea dx, msg_no_div
- mov ah, 9
- int 21h
- inc si
- jmp op_div
- @@_exit:
- int 20h
- _input proc
- push si
- push cx
- xor di,di
- mov ah, 9
- int 21h
- mov dx,bx
- mov ah, 0ah
- int 21h
- mov si, dx
- add bl, [si+1]
- add bx, 2
- mov [bx],'$'
- add si, 2
- cmp byte ptr [si], "-"
- jnz ii1
- mov di,1
- inc si
- ii1:
- xor ax,ax
- mov bx,10 ;
- ii2:
- mov cl,[si]
- cmp cl,'$'
- jz endin
- cmp cl,'0'
- jl er
- cmp cl,'9'
- ja er
- sub cl,'0'
- mul bx
- add ax,cx
- inc si
- jmp ii2
- er:
- int 20h
- endin:
- cmp di,1
- jnz ii3
- neg ax
- ii3:
- pop cx
- mov si,cx
- mov [si], ax
- pop si
- ret
- _input endp
- _write proc
- push si
- push bx
- lea si,d
- mov bx,10
- xor cx,cx
- lea di,c
- cmp [di], -1
- jg @@asc2
- mov [si], '-'
- inc si
- neg ax
- @@asc2:
- xor dx,dx
- div bx
- add dx,48
- push dx
- inc cx
- cmp ax,0
- jz @@rever
- jmp @@asc2
- @@rever:
- pop dx
- mov [si], dl
- inc si
- dec cx
- cmp cx, 0
- jz @@end
- jmp @@rever
- @@end:
- mov ah, 9
- lea dx, d
- int 21h
- pop bx
- pop si
- ret
- _write endp
- _fillchar proc
- push si
- xor si, si
- fcl1:
- cmp si, 10
- je fclend
- mov d[si], '$'
- inc si
- jmp fcl1
- fclend:
- pop si
- ret
- _fillchar endp
- _fillcharc proc
- push si
- xor si, si
- fclc1:
- cmp si, 10
- je fclend
- mov c[si], '$'
- inc si
- jmp fcl1
- fclcend:
- pop si
- ret
- _fillcharc endp
- _fillcharbuff1 proc
- push si
- xor si, si
- fclb1:
- cmp si, 10
- je fclbend
- mov buff1[si], '$'
- inc si
- jmp fclb1
- fclbend:
- pop si
- ret
- _fillcharbuff1 endp
- end start
- code ends
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement