Guest User

Untitled

a guest
Aug 26th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     .model tiny        
  2.     .code
  3.     .386               
  4.     org 100h
  5. start:
  6. vvod1:                 
  7.     xor eax,eax        
  8.     xor edx,edx        
  9.     call clrscr
  10.     mov ah,9           
  11.     mov dx,offset message1         
  12.     int 21h            
  13.     mov ah,08h             
  14.     int 21h            
  15.     cmp al,'+'         
  16.     je cloj            
  17.     cmp al,'-'         
  18.     je vich            
  19.     cmp al,'/'
  20.     je dele            
  21.     cmp al,'*'
  22.     je rr1                             
  23.     jmp rr             
  24. rr1:    jmp umnoj          
  25. rr: cmp al,'q'         
  26.     je quit
  27.     cmp al,'Q'
  28.     je quit
  29.     jmp short vvod1        
  30. quit:  
  31.     ret            
  32. cloj:                  
  33.     call clrscr        
  34.        
  35.     call aa1           
  36.     push dx            
  37.     call bb1           
  38.     pop dx                     
  39.     add ax,dx          
  40.        
  41.     call print
  42.    
  43.     call endstrd
  44.     mov ah,9             
  45.     mov dx,offset message2     
  46.     int 21h
  47.     mov ah,08h
  48.     int 21h            
  49.     jmp vvod1
  50. vich:                  
  51.    
  52.     call clrscr        
  53.     call aa1           
  54.     push dx
  55.     call bb1           
  56.    
  57.     pop dx
  58.     sub dx,ax          
  59.     mov ax,dx          
  60.    
  61.     call print         
  62.    
  63.     call endstrd
  64.     mov ah,9           
  65.     mov dx,offset message2         
  66.     int 21h
  67.     mov ah,08h
  68.     int 21h            
  69.     jmp vvod1  
  70.  
  71. dele:                  
  72.     call clrscr        
  73.     call aa1           
  74.     push dx
  75.     call bb1           
  76.    
  77.     pop dx
  78.     xchg dx,ax
  79.     mov cx,dx          
  80.     xor dx,dx          
  81.     div cx             
  82.  
  83.     call print
  84.    
  85.     call endstrd
  86.     mov ah,9           
  87.     mov dx,offset message2     
  88.     int 21h
  89.     mov ah,08h
  90.     int 21h            
  91.    
  92.  
  93.     jmp vvod1
  94. umnoj:                 
  95.     call clrscr        
  96.     call aa1           
  97.     push dx
  98.     call bb1               
  99.     pop dx
  100.    
  101.     mul edx            
  102.  
  103.     call print
  104.    
  105.     call endstrd
  106.     mov ah,9           
  107.     mov dx,offset message2         
  108.     int 21h
  109.     mov ah,08h
  110.     int 21h            
  111.     jmp vvod1
  112. clrscr:
  113.     xor dx,dx          
  114.     mov ah,02h         
  115.     int 10h            
  116.     mov bl,0000111b        
  117.     mov cx,25*80           
  118.     mov ax,0920h           
  119.     int 10h            
  120.     ret
  121.     endp
  122. aa1:                   
  123.     mov dx,offset aaaa
  124.     mov ah,9   
  125.     int 21h
  126.     call mover
  127.     mov dx,ax          
  128.     ret
  129.     endp
  130. bb1:                   
  131.     mov dx,offset bbbb
  132.     mov ah,9   
  133.     int 21h
  134.     call mover
  135.     ret
  136.     endp
  137.  
  138. mover: 
  139.     mov dx,offset bufer    
  140.     mov ah,0ah         
  141.     int 21h            
  142.     mov dx,offset endstr       
  143.     mov ah,9               
  144.     int 21h                
  145.  
  146.     xor di,di          
  147.     xor ax,ax          
  148.     mov cl,blength
  149.     xor ch,ch
  150.     xor bx,bx
  151.     mov si,cx          
  152.     mov cl,10          
  153. tohex:
  154.     mov bl,byte ptr bconteg[di]
  155.     sub bl,'0'         
  156.     jb  tata           
  157.     cmp bl,9           
  158.     ja  tata           
  159.     mul cx             
  160.     add ax,bx              
  161.     inc di             
  162.     cmp di,si              
  163.     jb tohex
  164.     jmp tra
  165. tata:   jmp vvod1          
  166. tra:    ret
  167.     endp
  168.  
  169. print:
  170.    
  171.     mov ebx,0ah        
  172.     xor cx,cx          
  173.  
  174. divloop:
  175.     xor edx,edx        
  176.     div ebx            
  177.     add edx,'0'        
  178.     push edx           
  179.     inc cx             
  180.     test eax,eax           
  181.     jnz divloop        
  182. restore:
  183.     pop eax            
  184.     mov edx,eax          
  185.     mov ah,2           
  186.     int 21h            
  187.     dec cx             
  188.     cmp cx,0           
  189.     jne restore        
  190.     ret
  191.     endp
  192.  
  193. endstrd:
  194.     mov dx,offset endstr       
  195.     mov ah,9           
  196.     int 21h            
  197.     ret
  198.     endp
  199. ret
  200. message1 db "PRESS",0dh,0ah
  201.      db "+ for add. a+b.",0dh,0ah
  202.      db "- for sub. a-b",0dh,0ah
  203.      db "/ for div. a/b",0dh,0ah
  204.      db "* for mul. a*b",0dh,0ah
  205.      db "q for quit",0dh,0ah,'$'   
  206. message2 db "Press any key",0dh,0ah,'$'
  207. aaaa     db "a=",'$'
  208. bbbb     db "b=",'$'
  209. endstr   db 0dh,0ah,'$'  
  210. enderes  db ' ',0dh,0ah,'$'
  211. bufer    db 5              
  212. blength  db ?              
  213. bconteg:               
  214. hexstring equ bconteg
  215. end start
Add Comment
Please, Sign In to add comment