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 4258586
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:40:08+00:00 2026-05-21T05:40:08+00:00

First off, this is homework. I’m trying to read a 5 digit number into

  • 0

First off, this is homework.

I’m trying to read a 5 digit number into the register bx. The number is assumed to be no greater than 65535 (16 bits). Below is how I am attempting to do so.

However, when I attempt to print the number, I am only printing the very last digit that was entered. Which leads me to guess that when I add another number to bx it is overwriting the previous number, but I am unable to see the problem. Any help would be appreciated, I’m almost certain that it is something small I’m overlooking :-/

mov cx,0x05 ; loop 5 times
    mov bx,0    ; clear the register we are going to store our result in
    mov dx,10   ; set our divisor to 10

read:
    mov ah,0x01     ; read a character function
    int 0x21        ; store the character in al
    sub al,0x30     ; convert ascii number to its decimal equivalent
    and ax,0x000F   ; set higher bits of ax to 0, so we are left with the decimal
    push ax         ; store the number on the stack, this is the single digit that was typed
    ; at this point we have read the char, converted it to decimal, and pushed it onto the stack
    mov ax,bx       ; move our total into ax
    mul dx          ; multiply our total by 10, to shift it right 1
    pop bx          ; pop our single digit into bx
    add bx,ax       ; add our total to bx
    loop read       ; read another char
  • 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-05-21T05:40:09+00:00Added an answer on May 21, 2026 at 5:40 am

    When using the MUL opcode, there are three different results:

    • 8 bit – results are stored in ax
    • 16 bit – results are stored in dx:ax
    • 32 bit – results are stored in
      edx:eax

    So when you perform your multiplication, the instruction overwrites dx with zero in your case. This means that each subsequent use of the mul opcode is multiplying by zero.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off, this isn't homework ;). I'm trying to create a wordsearch game from
First off, this is part of an extra credit homework, so please do not
So first off, this is a homework assignment, so please don't write any code
So, first off, this is homework, albeit not mine. It's my brother-in-law's. He asked
First off, this is a homework question so vector libraries and string libraries are
First off, let me say that this is not homework (I am an A-Level
First off this isn't for any homework question, it's just on a general type
First off, this is homework, but I am simply looking for a hint or
First off I use this code to make the navigation bar always stay fixed;
First off the html row looks like this: <tr class=evenColor> blahblah TheTextIneed blahblah and

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.