Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8265539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:50:37+00:00 2026-06-08T04:50:37+00:00

.MODEL SMALL .STACK 64 .DATA MSGA DB 13,10,Input first number: ,$ MSGB DB 13,10,Input

  • 0
.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

I am new to Assembly language and I’m getting a problem with the DIV operation.

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:50:39+00:00Added an answer on June 8, 2026 at 4:50 am

    8-bit division using DIV instruction requires AX for dividend and an operand for the divisor.

    I’ve corrected the division part of the code and the stack size. Stack size should be at least 1000, or your program might crash due to insufficient stack storage. Below is the code.

    .MODEL SMALL
    .STACK 2000
    .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
    
    ; divide
    MOV AH, 0 ; prepare dividend
    MOV AL, BL
    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
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

.MODEL SMALL .STACK 1000 .DATA MSGA DB 13,10,Input first number: ,$ MSGB DB 13,10,Input
.model small .stack 100 .data .code mov ah,00h mov al,0e3h mov dx,00h int 14h
I need to create an executable from the next assembly code: .MODEL SMALL .DATA
I'm working with a small model in Entity Framework 4.0. I'd like to have
I'm writing a small program to record reading progress, the data models are simple:
model.py: class Tribes(Group): members = models.ManyToManyField(User, related_name='tribes', verbose_name=_('members')) i want to store a number
We're developing a data heavy modular web application stack with java but have little
I am using the Model-View pattern on a small application I'm writing. Here's the
I need to show all numbers from matrix(3x3) where number has two first bits
Im currently working on a small project in which I need to model the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.