Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dosseg
- .model small
- .stack 200h
- .data
- a1 dw 5
- b1 dw ?
- c1 dw ?
- res dw 0
- Sa1 db 'Input A: $'
- Sb1 db 0ah,'Input B: $'
- Sc1 db 0ah,'Input C: $'
- Sres db 0ah,'Res=$'
- ; ВВОД ДАННЫХ ЧЕРЕЗ КОНСОЛЬ
- cr = 0dh ;
- lf = 0ah ;
- string db 255, 0, 255 dup (?)
- errmsg db 'Недопустимый символ, можно '
- db 'использовать только цифры',cr,lf,'$'
- negflag dw ?
- .code
- IntegerIn proc
- start: mov ah,0ah;
- lea dx,string
- int 21h
- xor ax,ax;
- lea si,string+2;
- mov negflag,ax;
- cmp byte ptr [si],'-';
- jne m2;
- not negflag;
- inc si;
- jmp m3;
- m2: cmp byte ptr [si],'+';
- jne m3;
- inc si;
- m3: cmp byte ptr [si],cr;
- je ex1
- cmp byte ptr [si],'0';
- jb err1;
- cmp byte ptr [si],'9';
- ja err1;
- mov bx,10;
- mul bx
- sub byte ptr [si],'0';
- add al,[si];
- adc ah,0
- inc si;
- jmp m3;
- err1: lea dx,errmsg
- mov ah,9
- int 21h
- jmp start;
- ex1: cmp negflag,0;
- je ex;
- neg ax;
- ex: ret
- IntegerIn endp
- IntegerOut proc
- xor cx,cx;
- mov bx,10;
- cmp ax,0;
- jge m;
- neg ax;
- push ax;
- mov ah,2;
- mov dl,'-'
- int 21h
- pop ax;
- m: inc cx;
- xor dx,dx;
- div bx;
- push dx;
- or ax,ax;
- jnz m;
- m1: pop dx;
- add dx,'0';
- mov ah,2;
- int 21h
- loop m1;
- ret;
- IntegerOut endp
- ;РЕШЕНИЕ, С КОТОРЫМ ЕСТЬ ПРОБЛЕМЫ
- Solve proc near
- Push bp
- mov bp, sp
- mov ax, [bp+10] ;res
- mov bx, [bp+8] ;c1
- mov cx, [bp+6] ;b1
- mov dx, [bp+4] ;a1
- cmp cx, dx
- jg metka1
- metka1:
- cmp bx, cx
- jg metka2
- metka2:
- add ax, 1
- pop bp
- ret 4 ;(?)
- Solve endp
- Programm:
- mov ax,@Data
- mov ds,ax
- mov a1, ax
- Mov ah,09
- Lea dx,Sa1
- Int 21h
- call IntegerIn ;ВВОД A1
- mov b1,ax
- Mov ah,09
- Lea dx,Sb1
- Int 21h
- call IntegerIn ;ВВОД B1
- mov c1,ax
- Mov ah,09
- Lea dx,Sc1
- Int 21h
- call IntegerIn ;ВВОД C1
- ;решение
- push a1 ;[bp+4]
- push b1 ;[bp+6]
- push c1 ;[bp+8]
- push res ;[bp+10]
- call solve
- mov res, ax ;из ax (который у нас в процедуре был) мы передаем значение в res
- ;вывод результата RES
- Mov ah,09
- Lea dx,Sres
- Int 21h
- mov ax,res ;хммм...
- call IntegerOut
- mov ax, 4C00h
- int 21h
- end Programm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement