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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:05:36+00:00 2026-06-08T11:05:36+00:00

I managed to write a code that accepts a 32-bit integer and converts it

  • 0

I managed to write a code that accepts a 32-bit integer and converts it to a digit-array to represent it in another number system
Question: How can i expand this to 64-bit?
In the Digital Mars C/C++ compiler:

void get_digits_asm()
{
    __asm
    {

        pushf       
        movd xmm0,eax
        movd xmm1,ebx
        movd xmm2,ecx
        movd xmm3,edx
        movd xmm4,edi

        mov eax,[variable_x]
        mov ebx,[number_system]
        mov ecx,0h
        mov edi,0h

        begin_loop:
        mov edx,0h
        div ebx             
        lea edi,digits  
        mov [edi+ecx*4],edx
        add ecx,01h
        cmp eax,ebx
        ja begin_loop

        mov edx,0
        div ebx
        lea edi,digits
        mov [edi+ecx*4],edx
        inc ecx
        mov [digits_total],ecx


        movd edi,xmm4//pop edi
        movd edx,xmm3//pop edx
        movd ecx,xmm2//pop ecx
        movd ebx,xmm1//pop ebx
        movd eax,xmm0//pop eax
        popf            
    }

}

When this function returns, it gives the LSB to MSB arranged array of digits.

Example: 5 is 101 in the number-system 2. 232343435 is 54545… in system 8. I want to learn how can i make this in 64 bit. My OS is 32 bit. My CPU is pentium-M centrino-laptop How can i do this?

  • 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-08T11:05:38+00:00Added an answer on June 8, 2026 at 11:05 am

    You use

     mov edx,0h
    

    before

     div ebx
    

    in your begin_loop:.

    If you want to process 64-bit numbers, then use the EDX register to store the upper 32 bits of you number. So, if you number is

    int64_t variable_x;
    

    then load it into EDX/EAX pair.

    Instead of

    mov eax,[variable_x]
    

    do

    mov esi, variable_x
    mov eax, [esi]
    mov edx, [esi + 4]
    

    I hope you get it. Sorry if I forgot the exact addressing rules of x86.

    Of course, since you destroy the EDX on each iteration, you might use the stack or one more register to store it.

    Your problem has nothing to do with the 64-bit long mode, DIV instruction supports 64-bit integers. They are just stored as pairs.

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

Sidebar

Related Questions

So far I have managed to write some code that should print the source
Can .NET (managed code) read and write to CouchDB? I would like to build
I trying to write a simple function to call unmanaged code from managed code.
I managed to write add program that upon the user click a button, he
I'm trying to write a managed library in C# that will act as an
I am tyring to write some Java code that basically just plays a short
After weeks of effort I have managed to write F# programs that use LLVM
A junior co-worker of mine managed to write very scary, scary code. printJob.Type =
I am trying to write some code that uses SQL to delete rows from
I'm trying to write some C++ code that accesses some OS-level things in Windows,

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.