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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:34:35+00:00 2026-05-28T04:34:35+00:00

;print out division message mov rcx, 0 ;zero out register mov rax, [input] mov

  • 0
;print out division message
mov rcx, 0                       ;zero out register
mov rax, [input]
mov rcx, [input2]
idiv rcx                        ;divide rax by rcx
mov rdi, rax                    ;for printing purposes
call print_int

I can’t seem to figure out why this isn’t dividing, I’m getting a enrror “Floating Point Exception” I’m using a 64bit machine and the values are integers not floating point…. ideas?

I know after the division takes place the quotient should be in rax, and the remainder should be in rdx i believe, but as of right now i’m just trying to get my hands on the quotient.

  • 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-28T04:34:36+00:00Added an answer on May 28, 2026 at 4:34 am

    Your function looks a little bit complicated to me. idiv works as expected for me here with this function:

    _mydiv:
      xor  %rdx, %rdx ; clear high bits of dividend
      mov  %rdi, %rax ; copy dividend argument into rax
      idiv %rsi       ; divide by divisor argument
      ret             ; return (quotient is in rax)
    

    Translated into NASM syntax and to the windows ABI, I think that would be something like:

    _mydiv:
      mov  r8, rdx    ; copy divisor argument to scratch register
      xor  rdx, rdx   ; clear high bits of dividend
      mov  rax, rcx   ; copy dividend argument into rax
      idiv r8         ; divide by divisor in scratch register
      ret             ; return (quotient is in rax)
    

    Are you maybe stomping on your parameters and confusing something along the way?

    Edit: looking at your code, it occurs to me that it might not be written as a proper function at all. The important steps are:

    1. Put dividend in RDX:RAX – for you that probably means clearing out RDX and putting the input dividend in RAX.
    2. Put divisor in some other register – you chose RCX, that should be fine.
    3. Divide – idiv rcx.
    4. Result will be in RAX.

    You should pay particular attention to step 1 – make sure that RDX:RAX has sane contents! Why you’re getting a floating point exception I can’t guess from the code you’ve shown.

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

Sidebar

Related Questions

I would like to print out a html table- it should divide data into
I need to print out data into a pre-printed A6 form (1/4 the size
Can i print out a url /admin/manage/products/add of a certain view in a template?
I'm trying to print out the date in a certain format: NSDate *today =
Attempting to print out a list of values from 2 different variables that are
I like to print out software requirements so I can easily mark them up,
I want to get print out invoice but also wanna set margins and page
I can print out a date nicely based on the user's locale. But how
I want to print out some debug messages in my erb template when it
i need to print out numbers 1-100 in a random order. the print statement

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.