title: How to use DIV operation in assembly
body: <pre><code>.MODEL SMALL
  .STACK 64
  .DATA
  
  MSGA DB 13,10,"Input first number: ","$"
  MSGB DB 13,10,"Input second number:","$"
  MSGC DB 13,10,"The quotient is: ","$"
  MSGD DB 13,10,"The modulo is: ","$"
  
  NUM1 db ?
  NUM2 db ?
  
  .CODE
  
  MAIN PROC NEAR
  
  MOV AX, @DATA
  MOV DS, AX
  
  ; get first number
  LEA DX, MSGA
  MOV AH, 09h
  INT 21h
  
  MOV AH, 01
  INT 21H
  SUB AL, '0'
  
  MOV BL, AL
  
  ; get second number
  LEA DX, MSGB
  MOV AH, 09h
  INT 21h
  
  MOV AH, 01
  INT 21H
  SUB AL, '0'
  
  MOV CL, AL
  MOV AL, BL
  
  ; divide
  DIV CL
  MOV NUM1, AL
  ADD NUM1, '0'
  MOV NUM2, AH
  ADD NUM2, '0'
  
  ; output quotient
  LEA DX, MSGC
  MOV AH, 09h
  INT 21h
  
  MOV DL, NUM1
  MOV AH, 02H
  INT 21h
  
  ; output remainder/modulo
  LEA DX, MSGD
  MOV AH, 09h
  INT 21h
  
  MOV DL, NUM2
  MOV AH, 02H
  INT 21h
  
  MOV AH, 4Ch
  INT 21h
  
  MAIN ENDP
  END MAIN
  </code></pre>
  
  <p>I am new to Assembly language and I'm getting a problem with the DIV operation.</p>
  
  <p>This should output the quotient and remainder if a 1-digit number is divided to a 1-digit number. What is wrong with my code?</p>