MPASM 24
[COAL] Division using two input numbers Guest on 11th December 2020 12:05:53 PM
  1.                        
  2.  
  3.     .model small
  4.     .stack 100h
  5.     .data
  6.     str1 db 10,13,'Quotient=','$'
  7.     str2 db 'Reminder=$'  
  8.     str3 db 'Enter divident: $'
  9.     str4 db 'Enter divisor: $'
  10.     divident db ?
  11.     divisor db ?
  12.     .code
  13. main proc
  14.     mov ax,@data
  15.     mov ds,ax
  16.     ;; show prompt
  17.     lea dx,str3
  18.     mov ah,9
  19.     int 21h
  20.     ;; take first input
  21.     mov ah,1
  22.     int 21h
  23.     sub al,48
  24.     mov ah,0
  25.     mov bx,ax
  26.  
  27.     call newline
  28.     lea dx,str4
  29.     mov ah,9
  30.     int 21h
  31.     ;; take second input
  32.     mov ah,1
  33.     int 21h
  34.     sub al,48
  35.     mov cl,al
  36.    
  37.    
  38.     mov ax,bx ;; divident
  39.     mov bl,cl  ; divisor
  40.     div bl
  41.     mov ch,ah
  42.     mov cl,al
  43.         call newline
  44.     lea dx,str2
  45.     mov ah,9
  46.     int 21h
  47.    
  48.     mov dl,ch
  49.     add dl,48
  50.     mov ah,2
  51.     int 21h
  52.    
  53.     lea dx,str1
  54.     mov ah,9
  55.     int 21h
  56.    
  57.     mov dl,cl
  58.     add dl,48
  59.     mov ah,2
  60.     int 21h
  61.    
  62.     mov ah,4ch
  63.     int 21h
  64.      
  65.     main endp
  66.    
  67.     newline proc    
  68.    
  69.          mov dl,10
  70.      mov ah,2
  71.      int 21h
  72.      mov dl,13
  73.      mov ah,2
  74.      int 21h
  75.      ret
  76.    
  77.     newline endp
  78.  
  79.    
  80.    
  81.     end main

Coding Base is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.