Linked Questions
16 questions linked to/from When and why do we sign extend and use cdq with mul/div?
1
vote
0answers
38 views
Getting integer overflow even though I CDQ and zeroout EDX (masm; x86) [duplicate]
When I try to divide, 1234567890 (10 digits; less than max unsigned int), I don't get int overflow
When I try to divide, 2345678901 (10 digits; less than max unsigned int), I get int overflow.
When I ...
0
votes
0answers
17 views
I need help on building a program that has two integers as input and outputs the 1st integer raised to the power of the 2nd in X86 assembly code [duplicate]
.text
Assignment: .asciz "Assignment 1b: inout\n" #string
.global main
formatstr: .asciz "%ld" #long interger 64 bits long
printstr: .asciz "%ld\n" #long ...
22
votes
7answers
18k views
Integer Vs Long Confusion
I have seen many believe in the following
VBA converts all integer values to type Long
In fact, even the MSDN article says
“In recent versions, however, VBA converts all integer values to type ...
8
votes
5answers
1k views
Why does integer division by -1 (negative one) result in FPE?
I have an assignment of expaining some seemingly strange behaviors of C code (running on x86). I can easily complete everything else but this one has really confused me.
Code snippet 1 outputs -...
11
votes
3answers
2k views
On which platforms does integer divide by zero trigger a floating point exception?
In another question, someone was wondering why they were getting a "floating point error" when in fact they had an integer divide-by-zero in their C++ program. A discussion arose around this, with ...
0
votes
2answers
5k views
Why should EDX be 0 before using the DIV instruction?
I noticed when EDX contains some random default value like 00401000, and I then use a DIV instruction like this:
mov eax,10
mov ebx,5
div ebx
it causes an INTEGER OVERFLOW ERROR. However, if I set ...
12
votes
1answer
937 views
Which 2's complement integer operations can be used without zeroing high bits in the inputs, if only the low part of the result is wanted?
In assembly programming, it's fairly common to want to compute something from the low bits of a register that isn't guaranteed to have the other bits zeroed. In higher level languages like C, you'd ...
5
votes
4answers
359 views
How to optimize DivMod for a constant divisor of 10
In Delphi math.pas unit there is a procedure DivMod that i want to convert it into inline and optimize it for divisor to be always 10 . But I dont know details of Pentagon ASM . What is the conversion ...
8
votes
3answers
183 views
CS:APP example uses idivq with two operands?
I am reading about x86-64 (and assembly in general) through the book "computer systems a programmer's perspective"(3rd edition). The author, in compliance with other sources from the web, states that ...
1
vote
2answers
496 views
Dividing with a negative number gives me an overflow in NASM
I'm teaching myself some assembly programming with x86-64 Mac OS. I'm trying to figure out why when it comes to dividing a positive integer with a negative integer gives me an overflow. For example, 5/...
2
votes
1answer
165 views
What is the use of this asm block using x86 DIV in c++?
Can someone help me understand benefit of using asm block for unsigned long long multiplication in terms of performance. It is related to competitive programming optimization. I guess it makes ...
2
votes
2answers
62 views
Why IDIV with -1 causes floating point exception?
As far as I understood, idiv %ebx will divide edx:eax (concatenated into 64-bit value, in that order) with 32-bit ebx.
However, when I try to divide 0x00000000:0xfffffffb (0 and -5) with 0xffffffff (-...
2
votes
2answers
62 views
Newtons Raphson Iteration issues
I am writing a 8bit integer newton raphson function in MASM X8086-32bit assembly and I think I am stuck in an infinite loop. The editor I have to use for class does not send an error for infinite ...
-1
votes
1answer
70 views
C++ assembler conversion problems
little bit of a problem here, tried to create assembly code which converts strings to integers. Unfortunately, I cannot find the reason why it "breaks", I input 54321 and it converts to 543418. All ...
0
votes
0answers
50 views
Strange results with dividing in assembler on intel 80368 32 bit
It gets stuck in an infinite loop in function "prebroj". It should count how many digits there are in my result number so i can return it as a string later and exit when %eax becomes 0. When I run it ...