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

  • Home
  • SEARCH
  • 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 8426797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:37:32+00:00 2026-06-10T04:37:32+00:00

I am programming in Tasm and want to input a 32 bit number. I

  • 0

I am programming in Tasm and want to input a 32 bit number.

I know that i have to input it digit by digit (i hope there is no one call function for number input)

This is my code

    .        .486
    .model small
    .code
    start:

    mov ebx, 0

    ; enter again and again untill enter is hit
    again:
    mov ah,01h
    int 21h
    cmp al, 13
    jz next
    mov dl, al
    mov eax, ebx
    mov ebx, 10
    mul ebx
    mov ebx, eax
    mov eax, 0
    mov al, dl
    add ebx, eax
    jmp again

    ; now find the digits back

    next:
    ; just testing to see if i got number
    mov edx, 13
    mov ah, 02h
    int 21h

    mov edx, 10
    mov ah,02h
    int 21h

    mov edx, ebx
    mov ah, 02h
    int 21h

    mov eax, ebx

    mov ebx, eax

    xor edx, edx
    xor cl, cl

    ; find digits and push into stack from last to first so when i pop i get digits back
    finddigit:
    xor edx,edx
    mov ch , 10
    div ch
    push dx ;taking risk dx dl
    inc cl
    cmp eax, 0
    jz print
    jmp finddigit


    ; stored into cl the number of digits

    print:
    cmp cl,0
    jz exit
    dec cl
    pop dx
    mov ah,02h
    int 21h
    jmp print


    exit:
    end start

i am stopping input at enter .

i am getting error NTVDM encountered a hard errror.

Thanks

This is my new modified code. It is working fine for some numbers like 2 and 123
but is failing for 333, 4444, 555; (i hope pushing and poping does not modify any registers other than specified):

.486
.model small
.code
start:

mov ebx, 0

; enter again and again untill enter is hit
again:
mov ah,01h
int 21h
cmp al, 13
jz next
mov cl, al
sub cl, 30h
mov eax, ebx
mov ebx, 10
mul ebx
mov ebx, eax
mov eax, 0
mov al, cl
add ebx, eax
jmp again

; now find the digits back

next:
; just testing to see if i got number
mov edx, 13
mov ah, 02h
int 21h

mov edx, 10
mov ah,02h
int 21h


mov eax, ebx

mov ebx, eax

xor ecx, ecx

mov ebx, ebp
; find digits and push into stack from last to first so when i pop i get digits back
finddigit:
xor edx,edx
mov ebp , 10
div ebp
push edx
inc cl
cmp eax, 0
jz print
jmp finddigit

; stored into cl the number of digits

print:
cmp cl,0
jz exit
dec cl
xor edx,edx
pop edx
add dl,30h
mov ah,02h
int 21h
jmp print


exit:
mov ah,4ch
int 21h               
end start

I am running this is MS-DOS CMD.exe window A pop up Error comes:

Error

  • 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-10T04:37:34+00:00Added an answer on June 10, 2026 at 4:37 am

    Assuming this is for DOS environment (due to int 21h):

    There are some bugs in your code.

    1. Read character function returns its output in al, that’s ok. But then you immediately destroy the value of read character with the following sequence:

        mov dl, al    ; the character read now in dl
        mov eax, ebx  ; eax is now 0 in the first loop
        mov ebx, 10   ; ebx is now 10
        mul ebx       ; the result of mul ebx is now in edx:eax,
                      ; the character read (in dl) is lost.
    

    So you can’t store the character in dl if you are going to do mul ebx, because mul reg32 outputs the result in edx:eax. You could store it eg. in cl or ch instead.

    2. Other bug which I notice is that you are attempting to multiply ASCII values by 10 (in the previous code). You should first subtract the value of ‘0’ of every read character before multiplication, that would be sub al, 30h or sub al, '0'.

    3. Third bug is in the following sequence:

       xor edx,edx
       mov ch , 10
       div ch
       push dx ;taking risk dx dl
       inc cl
       cmp eax, 0
       jz print
       jmp finddigit
    

    Edit: Here you are dividing ax by ch, which obviously does not work right for 32-bit division. As it seems that you want to have your dividend in eax, clear edx with xor edx, edx (as you do), and then divide edx:eax with a 32-bit register, eg. ebp, esi or edi (those seem to be unused in your code so far), and you’ll get the quotient in eax and the remainder in edx.

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

Sidebar

Related Questions

Programming language: Java Ok, so I want to have a BufferedImage that keeps rotating
When programming in OS X, one of the great annoyances to me is that
Many programming languages require a special user-written function that marks the begin of the
(programming in iPhone objective-C) I have a class level NSString* that I create, add
Programming In Scala explains that tuples' _N numbers are one-based, instead of zero-based, because
While programming in java is there any time that I as the programmer should
Programming a 8-bit AVR microcontroller I've came across a behavior that is shown on
Programming language books usually explain that value types are created on the stack, and
Android programming. I have a json returning the date from a database as a
Programming in C#.NET 4.0 is my latest passion, and I would like to know

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.