Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- model small
- .386
- .stack 100h
- .data
- str1 db 'Input two numbers:',0Dh,0Ah,'$'
- str2 db 'Wrong Number. Please input correct number:',0Dh,0Ah,'$'
- max db 10
- len db 0
- buffer db 11 dup(0)
- ten dw 10
- digit dw 0
- x dq 0
- x1 dq 0
- x2 dq 0
- delta_x dq 0
- max_y dq -999.9
- min_y dq 999.9
- screen_height dw 480
- screen_width dw 639
- func_arr dq 640 dup(0)
- func_arr_scale dw 640 dup(0)
- .code
- start:
- mov ax,@data
- mov ds,ax
- mov ah,09h
- lea dx,str1
- int 21h
- finit
- input:
- lea di,x1
- call input_number
- cmp al,01h
- je re_input
- mov ah,0Eh
- mov al,0Ah
- int 10h
- mov ah,0Eh
- mov al,0Dh
- int 10h
- lea di,x2
- call input_number
- cmp al,01h
- je re_input
- fld x1
- fld x2
- fcom st(1)
- fstsw ax
- fwait
- sahf
- jbe re_input
- fstp x2
- fstp x1
- draw:
- fld x2
- fld x1
- fsubp st(1),st(0)
- fild screen_width
- fdivp st(1),st(0)
- fstp delta_x
- fld x1
- fstp x
- mov cx,screen_width
- xor di,di
- calc_step:
- call func
- fld x
- fld delta_x
- faddp st(1),st(0)
- fstp x
- loop calc_step
- scale:
- fild screen_height
- fld max_y
- fld min_y
- fsubp st(1),st(0)
- fdivp st(1),st(0)
- xor si,si
- mov cx,640
- xor di,di
- loop_scale:
- fld max_y
- fld func_arr[si]
- fsubp st(1),st(0)
- fmul st(0),st(1)
- fistp func_arr_scale[di]
- add di,02h
- add si,08h
- loop loop_scale
- fstp min_y
- drawing:
- mov ah,00h
- mov al,12h
- int 10h
- mov si,1278
- mov cx,640
- xor bh,bh
- draw_loop:
- push cx
- dec cx
- mov ah,0Ch
- mov al,15
- mov dx,func_arr_scale[si]
- int 10h
- sub si,2
- pop cx
- loop draw_loop
- mov ah,00h
- int 16h
- mov ax,4C00h
- int 21h
- re_input:
- mov ax,03h
- int 10h
- mov ah,09h
- lea dx,str2
- int 21h
- jmp input
- func proc
- fld x
- fcos
- fmul st(0),st(0)
- fmulp st(1),st(0)
- fld x
- fmul st(0),st(0)
- fmul st(0),st(0)
- fld x
- fsin
- fmul st(0),st(0)
- fmul st(0),st(0)
- fmulp st(1),st(0)
- faddp st(1),st(0)
- comp_max:
- fcom max_y
- fstsw ax
- fwait
- sahf
- ja bigger
- comp_min:
- fcom min_y
- fstsw ax
- fwait
- sahf
- jb smaller
- jmp end_calc
- bigger:
- fst max_y
- jmp comp_min
- smaller:
- fst min_y
- end_calc:
- fstp func_arr[di]
- add di,08h
- ret
- func endp
- input_number proc
- mov ah,0Ah
- lea dx,max
- int 21h
- xor ax,ax
- xor bx,bx
- xor cx,cx
- xor si,si
- xor dx,dx
- fldz
- mov al,buffer[si]
- inc si
- cmp al,'-'
- jne plus
- mov dh,01h
- jmp number
- plus:
- cmp al,'+'
- jne dot
- jmp number
- dot:
- cmp al,'.'
- jne digits
- mov dl,01h
- next_is_digit:
- mov al,buffer[si]
- inc si
- start_parse:
- dec si
- number:
- xor ax,ax
- mov al,len
- cmp si,ax
- je fraction
- mov al,buffer[si]
- inc si
- cmp al,'.'
- jne digits
- cmp dl,01h
- je error_input
- mov dl,01h
- jmp next_is_digit
- digits:
- cmp al,'0'
- jb error_input
- cmp al,'9'
- ja error_input
- inc bx
- fild ten
- fmulp st(1)
- sub al,'0'
- mov digit,ax
- fiadd digit
- cmp dl,00h
- je number
- inc cx
- jmp number
- fraction:
- cmp cx,00h
- je final
- fild ten
- fdivp st(1),st(0)
- loop fraction
- final:
- cmp bx,00h
- je error_input
- cmp dh,01h
- jne is_over
- fchs
- is_over:
- mov al,00h
- store:
- fstp qword ptr [di]
- ret
- error_input:
- mov al,01h
- jmp store
- ret
- input_number endp
- end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement