How to use idiv assembly. 7k 5 …
You would have better shown us more from your code.
How to use idiv assembly The source In this tutorial, we will see different integer division instructions supported by 8086 microprocessors. 0xFF, or you'll get a division overflow. Syntax. I admit I didn't read the whole edit history. IDIV operation in assembly When both the dividend and the divider are positive you can safely use div instead of idiv. – For assembly language programs the Least Significant Quadword (LSQ) is added with the add instruction and then immediately the Most Significant Quadword division of signed values. CWD is an instruction that will sign-extend the AX register into DX:AX. NASM on linux: Using This should probably use idiv, or cast the inputs to unsigned. into RAX for 64-bit idiv rcx, like for INT64_MIN / -1 which also faults on x86-64. XOR DX,DX (before DIV). broadcasts the sign bit of eax into every bit of edx. The first implicit argument is the dividend, a 64-bit argument in edx:eax See: Can I use Intel syntax of x86 assembly with GCC? Share. assembly imul and idiv. because they require a lot of CPU cycles You haven't defined what "it won't work" means, but I'm going to assume that the number displayed by the last printf doesn't match what you inputted. 8086 assembler,INT 16,2. While you're at it, I'd suggest a comment to point out that it's intentional that you don't zero EDX inside the loop; that the remainder from the previous division is the upper half of the input to the next limb. Note that the x86 expects the result of the division to fit in one register, so you'll need to zero edx before the division: Find centralized, trusted content and collaborate around the technologies you use most. 1. It's not clear what conversion does. Irvines's WriteDec should be replaced by WriteInt which handles the argument EAX as signed number. So fdiv should devide st(0)/size and the result should be stored in st(0), right? Because Intel uses little endian, it does not matter that you're only using a single byte, the mov al,[some_address_as_before] will still work. mov ah,01h int16h, how to use it to change the direction of the snake. Myth busting. Your question is tagged (But yes, with a random integer, not a compile-time-constant, int result = a % b would use idiv. In this case, since you are only dividing one digit numbers, the best solution is to simply clear AH:. printing coordinates assembly 8086. To quote from the documentation:. Note, that despite them using the whole AX, it is not a true 16-bit divide. If you use IDIV on what you think is usigned integers (or DIV on signed integers), the CPU will happily do that for you and the wrong result (or a division Ah, ok, I was wondering how that div eax, ebx got in there in an example based on working code! (and yes, I could tell it must not have been copy/pasted verbatim). inc include \masm32\include\kernel32. I'm assuming this can only be done using shifts operations since imul only works for multiplying 32-bits numbers. 8. It's the value you put there because you want to divide it The CDQ instruction takes a 32-bit value in EAX and converts it into a 64-bit value in EDX:EAX (by copying the sign bit of EAX into every bit of EDX). 1: the sum was positiv, the You can't use al as divisor, because the command div assumes ax to be the dividend. The logic is, if n*var < x, where x is the number to divide and var is the number to divide by, increment n by 1 and repeat. Probably the cortex-a5 is the best one to use as it supports idiv and is a lowest common denominator. Since you did a byte division div bl you obtained a quotient in AL and a remainder in AH. Much better to use idiv with all explicit operands. e. Performs an unsigned division of two operands. AH must be smaller than a divisor - otherwise "Division overflow" is thrown. DIV performs the division 6/-2 positively (6/4294967294) and gets the result 0 = 0x00000000, with IDIV the result is correct: -3 = Please provide more details on what do you wish to achieve with this code. For unsigned, remainder and modulus are the same thing. – jfMR. On a big endian architecture you'd need to adjust the address by 3 bytes. idiv/div leave all flags undefined. Since ah is the most significant part of ax that means ax will have the value 0x9XY (where XY are any hexadecimal digits) when you do the division. Divides (signed) the value in accumulator registers (dividend) by the source operand (divisor) and stores the result in the AX (AH:AL), DX:AX, or EDX:EAX registers. 3681944047089408e-0043 (for the fussy people out there it is actually a long double). This step is necesssary for the IDIV CX instruction to work Just like everything else in assembly there are many ways to do multiplication and division. The edit done by the OP (from idiv 10 to idiv ebx) should not have been done either! I do like your suggestion to put a warning comment in the question. ; fine. This shift moves 1 on EAX´s MSB, and you have a positive result 0x80000000 greather than Your assembler code has some bugs: It clobbers EBX which is a saved register (i. I am writing this assembly program in 8086, but it is not working properly. I'm learning 80386 from PC Assembly by paul caurter. Division operation uses up the AX register. ) The title question is a duplicate of Assembly - How to score a CPU instruction by latency and throughput, the question body is a near-duplicate of Idiomatic way of performance evaluation? and other more specific microbenchmark-methodology questions. So here's the recap of all the pain I've been through thanks to intel: This article is useful for people using intel x86_64 architecture with the GNU assembler, gas. BMI2 mulx uses an implicit rdx input operand because its purpose is to allow multiple dep chains of add-with-carry for extended-precision multiply. According to line by line execution scheme, if JG is not met, the next line will be ⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. 386 with my current process. mul source If the operand is byte sized, it is multiplied by the byte in the AL register and the result is stored in the 16 bits of AX. Q&A for work. – Michael. 8086 assembly on DOSBox: Bug with idiv instruction? Related. (This is the opposite of AAM, which does accept an immediate operand, but only divides AL, not AX). To multiply by small assemble-time constants, it's often worth it to use a shift and add or subtract instead of multiplying I am trying to run the following code in assembly: mov %si, %ax mov $15, %si div %si mov %eax, %esi When I make my program, it compiles, but at runtime it gives me a floating point exception. Use the address calculation options of lea (multiplication only). We will also provide assembly program examples of each divide instruction. We would understand better what you need if we were shown the actual text in Danswer and Drem. Signed divide RDX:RAX by r/m64, with result stored in RAX ← Quotient, RDX ← Remainder. The quotient result of the division is stored into EAX; The remainder is placed in EDX. Snake Assembly 8086: not moving correctly. e. The value of AX after the cbw instruction will be FFF0h (a 16-bit -16 value, just like AL was Find centralized, trusted content and collaborate around the technologies you use most. If you use gcc to "compile" your assembly file into an executable, and/or use gcc to link the assembler-generated *. You don't need an alternative to imul or mul; the one-operand form was part of 8086, not added later. Sorting strings in 8086 Assembly. The problem is that if the 64-bit signed result is large enough and/or if n3 is small enough, an overflow will result and idiv will throw a #DE exception. I want to divide the whole value (64-bits) by 3, not only 32-bits, and store it in 2 registers. use cents instead of dollars), but output with a . Use shifts and adds/subs instead of multiplication. Your orginal code isn't far off. DivNeg: neg ebx cdq div ebx neg eax jmp Done1 Integer overflow exception on idiv instruction occurs when result of n-bit division can not fit into n-bit register. The goal was for program to calculate average, but I get very wrong output every single time and I don't know why. But if you want modulo in the sense of Euclidean or floored division, not truncating (quotient rounds toward zero) where -1 % 2 == -1, then you'd want more IDIV CX divides the 32-bit value DX:AX by CX, and stores the quotient in AX and the remainder in DX. IDIV r/m64. The idiv instruction divides the contents of the 64-bit integer EDX:EAX by the specified operand value. If the divisor is a signed 64-bit value, you don't need to do anything with it. The quotient result of the division is stored into EAX; The remainder Divides the (signed) value in the AX, DX:AX, or EDX:EAX (dividend) by the source operand (divisor) and stores the result in the AX (AH:AL), DX:AX, or EDX:EAX registers. The quotient must be in the range 0x00. and it seems like dx register always have content zero even after div has been executed. . Or for (unsigned long)-1 / 1 with signed division like you're doing by zero-extending into RDX:RAX Find centralized, trusted content and collaborate around the technologies you use most. It is interesting because it computes not only the division, but The code you suggested uses fld and fst, which both operate on floating point values, so the result you get won't be what you expect it to be. The size of the divisor (8-, 16- or 32-bit The DIV (Divide) instruction is used for unsigned data and the IDIV (Integer Divide) is used for signed data. MUL r8 wil multiply r8 with al and store the result in ax. Related. The lower Bits are in raxand the higher ones in rdx. Your EDX value is 1 and you divide EDX:EAX by 2, which results into a bit shift to right. I think it's because I can't move a constant into a register, but to use the mul/div command it requires a value to be in EAX register. o file into an executable, all necessary dependent libs This is why cdq / cqo is used to set up for idiv, while xor edx,edx is used to set up for div. Use idiv esi like a normal person in your final example. Even if you are using a 64-bit data type, practice shows me that the majority of divisions in a (general purpose) program could still do with just using the built-in div instruction. I'm not the most experienced assembly programmer, and I ran into the "cqo", "cdq" and "cwd" instructions, which are all valid x86_64 assembly. It's like C where unsigned x=; x *= y; has the same width for the result as the inputs. With an 8-bit division, the dividend is held in AX, with AH being the high bit and AL being the low bit (naturally enough). Posted on January 14, 2017 April 18, 2017 by X86 Assembly. Commented The cbw instruction sign-extends a byte into a word. Also JMP @WITHNEG on this line of code @SUB : MOV AL, NUM1 CMP AL, NUM2 JG @WITHOUTNEG JMP @WITHNEG is totally unnecessary as the next line is @WITHNEG:. The fact that you're passing "Your Number Is %d \n" as the format string to scanf is a problem, since it contains a bunch of non-format specifier characters. How to find remainder without using div in Assembly. Connect and share knowledge within a single location that is structured and easy to search. auto-vectorizing. Commented May 24, 2017 at 11:30 @Johan idiv has the same Just to be clear, idiv gives you the signed remainder just as easily, with cdq / idiv for 32-bit operand size for example (When and why do we sign extend and use cdq with mul/div?). Looking back on my book it uses idiv with cdq but uses ecx instead of ebx. The dividend is implicit, and the divisor is the one explicit operand. The compiler doesn't have to zero or sign-extend inputs to 64 bit for you, in either of the Both 8-bit DIV and IDIV use the whole AX as input, so you need to set AH to a valid value. Syntax idiv <reg32> idiv <mem> Examples There's nothing called "Intel-based assembly language". Improve this answer. Therefore you should clear EDX prior to the division if the value you want to divide is 32 bits (fits in EAX alone). @PeteWilson if you'd like to put your reply in an answer, I'll accept it. Now, if any of the numbers is signed but shorter than idiv expects, you need to sign-extend that number. 6. The format for the DIV/IDIV instruction −. Not sure I quite understand IDIV and can't really find anything on it. For DIV, you set AH=0. You still need to setup DX. Keep the following things in mind: rand() is a standard library function, so you need to link your program with that or the function isn't found / the executable can't run. This is an example for dividing bp by 7 mov ax,bp // ax is the dividend mov bl,7 // prepare divisor div bl // divide ax by bl The idiv instruction takes 2 arguments in 3 registers. Problems with your idiv: There's no form of idiv that takes an immediate operand. 386 . If idiv simply set #DE on overflow, I could check to confirm that ((n1 * n2) / n3) * n3 + ((n1 * n2) mod n3) = (n1 * n2). As such, different instructions are used for unsigned division (div) and signed division (idiv). in between. just because some instruction is called "DIV", it doesn't mean it works as you expect. IDIV operation in assembly (understanding) 2. But only found solutions for dividing by 2^n What kind of competition is it where fewer but slower instructions is better, even when the program is compiled with -O3 not -Os?-O3 will spend extra code size all over the place to gain speed, e. IDIV gives you in this case only three possible remainders: {-1,0. ; cdq sign-extends eax into edx:eax, i. This means that the two's-complement value of AX will be the same, but the binary representation will be different. imul ecx, esi does ecx *= esi like you'd expect, without touching EAX or EDX. What is IDIV in assembly language? Description. The question should be tag with x86 – phuclv. But your code looks like you didn't check the instruction manual. That is possible because idiv and div divide the whole register pair EDX:EAX. print the division result and the leftovers from the result. Dividing and rounding in assembly This video is on the DIV instruction. For example, to add a pair of 64-bit numbers you could do something like this: mov eax, A_1 ; essentially C = A + B mov edx, B_1 add eax, edx ; note that for the low word, we just add mov C_1, eax mov eax, A_2 mov edx, B_2 adc eax, edx ; but for the high word, we Thanks guys, I was on the right track. The rdx:rax is fixed, idiv always uses that pair of registers for the dividend. inc includelib \masm32\lib\kernel32. My approach was to save rax, the lower Bits of the number, in another Register and left-shift the Bits from the rdx-Register bitwise into rax to Indeed, div and idiv will cause an "integer division exception", not "a floating-point exception". MOV ECX,9 CDQ ;this will clear EDX due to the sign extension IDIV ECX MOV EAX,EDX The second way is an optimization used when you modulo using a power of two, in this case you AND by one less than the power of two, eg: eax = eax % 8 becomes AND EAX,7. But this hypothetical new form of idiv would exist to save code-size and uops around normal uses of idiv that aren't widening. ; For the Remainder out parameter, you were not storing to the location it pointed to. When the dividend is positive and the divider is negative you can negate the divider, use div as before, but negate the quotient. 81. ;SECOND INPUT CALL SCAN_NUM ;AX/CX = AX IDIV CX The comment is wrong! IDIV CX will do a signed divide of DX:AX by CX. MASM - Rounding Integers. Assembly - Trying to reverse string, but it adds an extra character on the final string. MOV CL, AL MOV AL, BL MOV AH, 0 ; clear AH ; divide DIV CL MOV Fortunately, to divide by 2, you don't really need to use div at all. 0: no remainder, the average is already correctly rounded, i. For both DIV and IDIV, all of the arithmetic status flags are undefined after idiv divides rdx:rax by the specified divisor. Search for 'intel mul' and 'intel div' to see the instruction details: For 8 bits: Using an 8 bit register r8 as argument (where r8 is one of the 16 8 bit registers),. Assembly sarl and idivl - interpreting. lib includelib On a IA-32 architecture how can i divide a signed number by 3 (e. 1} which means:-1: the sum was negative, the number behind the decimal point is -0. Your current code is already broken because you don't sign-extend indexMat into AX. See What is the difference between 'asm', '__asm' and '__asm__'? When using DIV with a 32-bit operand, it will divide the 64-bit value in EDX:EAX (high DWORD in EDX, low DWORD in EAX) by the operand and put the quotient in EAX and the remainder in EDX. (See the x86 tag wiki for a link showing when each form of every instruction was added). @PeterCordes Noted. Returning result to The idiv instruction divides the contents of the 64 bit integer EDX:EAX (constructed by viewing EDX as the most significant four bytes and EAX as the least significant four bytes) by the specified operand value. This means that you need to have a suitable value in both AH and AL before dividing. In the simple/general case: unknown value at runtime. 3. c doesn't emit. And use movsx rcx, esi , or movsx rsi, esi in your first example. Likewise, if the dividend is a signed 128-bit value, you don't need to do anything with it, just load the top 64 bits of it into rdx and the low 64 bits into rax. For Everything you did in your program is right except one. Here is my current code:;calculate average : sum / numCount = average calculateAverage: mov edx, 0 mov eax, sum mov ebx, numCount idiv ebx mov average, eax mov edx, OFFSET averageMessage ; "The average is " call writestring mov ebx, average call You can use fixed-point arithmetic, calculate the division with integers (e. ) in assembly, because I need to be able to do maths in my own programming language. Before the division you have to multiply by 100/1000 (see @Chris Halls answer line 3). trusted content and collaborate around the technologies you use most. Use movsx eax, byte [indexMax] before byte-size idiv. DIV/IDIV divisor The dividend is IDIV Instruction • IDIV (signed divide) performs signed integer division • Uses same operands as DIV Example: 8-bit division of –48 by 5 mov al,-48 cbw ; extend AL into AH mov bl,5 idiv bl ; The IDIV (signed divide) instruction performs signed integer division, using the same operands as the DIV instruction. However, the idea always works; use two sets of functions and ID at run time. For output you can divide by 100/1000 with remainder, and put a decimal point in between. You manage to show the quotient via temp, then answer, then temp1 I need to divide an unsigned 128-Bit number on a 64-Bit Processor at the Register rdx:rax with a 64-Bit divisor in rdi. If AH has a pre value stored in it, AX register will include that value and the final value of AX would be different than what you expect it div / idiv: divides edx:eax by the src. – user2922055. @MichaelPetch you are right, cdq sign extends eax into edx and it is therefore suited for idiv and not div. It compiles and gives me no warnings, but when I try to run it, it gives me a segmentation fault. So, I have an assembly function, which is called in C. So in the event of there being a remainder, the divider will round up the answer by 1. IDIV r/m32. 5, the average has to be subtracted by 1, i. Find centralized, trusted content and collaborate around the technologies you use most. mov eax, 174 mov edx, 181 xor eax, edx shr eax, 1 If you do insist on using a div for some reason, you want to use a different register. ) a value stored in 2 registers, edx:eax (a 64-bit value). An example? 00 00 00 A9 is the byte representation on 169, but it represents the floating point number +2. So basically I just figured out how to do those 4 simple operations (adding, diving etc. Intel has many different architectures with corresponding different assembly language. It is of course possible to use cqo/idiv from inline asm, you just normally don't want to. idiv executes signed division. The Kite plugin integrates with all the top editors and IDEs to give If you only want the low 32 bits of the result, use the 2-operand form of imul; it runs faster and doesn't have any implicit operands (so you can use whatever registers are most convenient). The last thing you set ah to before the division is 9. Learn more about Collectives Teams. See the other question for possible CPUs. Therefore the value of DX prior to the IDIV instruction matters, and you should either sign-extend AX into DX using the CWD instruction (before IDIV), or clear DX using e. Syntax idiv idiv . Division + Modulo in assembly x86. inc include \masm32\include\masm32. x86 Assembly - idiv to get decimal places. Your lines 26 and 27 are already setting up rdx:rax correctly. For IDIV, you use CBW instruction to set AH=0 or (-1), depending on the sign of AL. And so, if you want to divide two integers as unsigned, you execute DIV with the values of the integers and if you want to make a signed division, you do the same with the IDIV instruction. – There's no FLAGS / control register / other hardware setting that will make div and idiv not raise #DE divide exception on divisor = 0 or on the quotient not fitting into the operand-size. avg = avg + 0. The proposed algorithm will not beat the internal div instruction. Using div is masochistic. Recall that \(\dfrac{dividend}{divisor} = quotient\). Also, why would you mov rcx,rsi instead of idiv rsi? (Or idiv esi, because you told the compiler you were only going to look at the low 32 bits of input registers by making the return type int. Do division by multiplying by the reciprocal value. Learn more about Collectives The reason to do this is because, even though there is an integer division instruction div/idiv in the I'm limited to using the . The denominator resides in a source operand and it First, MUL and DIV only take 1 argument. ) There is a way to compute the mod operation, without using DIV or IDIV in assembly x86 language? For instance, one could use DIV in order to take the remainder of the division. g. idiv divides a 16-, 32-, or 64-bit register value (dividend) by a register or memory byte, word, or long (divisor). The size of the divisor (8-, 16- or 32-bit operand) determines the particular register used as the dividend, quotient, and remainder. Follow edited May 23, 2017 at 8086 assembly on DOSBox: Bug with idiv instruction? and Why should EDX be 0 before using the DIV instruction? explain how to use signed or unsigned division instructions. For example:. And that is Find centralized, trusted content and collaborate around the technologies you use most. I am just trying to calculate an average. The quotient goes in AL, and the remainder goes in AH. So it still has to produce 2 outputs. quotient in eax, remainder in edx. intel-Based Assembly Language idiv. What's the difference between `lodsl` and `movl (%esi), %eax; addl How can I collect the remainders of a div instruction into a register so that it can be converted into a string and displayed to the console. In this series of 8086 microprocessor tutorials, we previously discussed; IDIV (signed numbers) AAD; 8086 DIV Instruction ( Unsigned Operands) The DIV instruction performs the division of two unsigned operands. I am working on something that will divide two numbers in assembly without using the MUL or DIV operators. The DIV instruction (and its counterpart IDIV for signed numbers) gives both the quotient and remainder. Kerrek SB thanks for explaining, could I was trying to work out how to calculate modulo 10 in assembly so i compiled the following c code in gcc to see what it came up with. ) Share. Not to be confused with cdqe, the 64-bit instruction that is a more compact form of movsxd rax, eax. 4. There's no form of div / idiv that ignores edx in the input. 7k 5 You would have better shown us more from your code. kquinn kquinn. (Note on the above code: it has not been tested, obviously, and I'm a little rusty on my assembly so there is probably something wrong with it, even though it's nice and short. 3) How To Use Add, Sub, Mul, Div Instructions. If you are dividing using AL only, It is an utmost necessity that you must first clear the AH register. After fadd operation the result should be in st(0). I am developing an assembly language program that will check whether an inputted number is divisible by 3 or not, now I am struggling to get things correct but my code is running. I do think though that by your edit you effectively produced another question. But, instead to use DIV, there are other options? How can I divide two numbers in Assembly without using DIV instruction but by using shift and add method? I did that with multiplication and here is my code: mov bl, 56H ;For example mov dl, 79H ;start mov bh, 00H mov dh, 00H xor di, di mov cx, 08H L1: shr dx, 1 ;shifting the multiplier jnc nxt add di, bx ;adding the multiplicand to the result This answer will use a technique named Division by Partial Quotients aka Chunking. the request from the program is: get 2 numbers, word size, from the user and divine them. model flat, stdcall option casemap :none include \masm32\include\windows. Assembly 8086 program. This is because, for instance, multiplying 127 with 127 is bigger than 8 bits (but never more than 16). Follow answered Mar 19, 2011 at 1:04. Sign extension is very simple. If you're clearing a register it's usually better to use xor a,a than using mov reg,0 the former encodes in fewer bytes and runs Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers; Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand; OverflowAI GenAI features for Teams; OverflowAPI Train & fine-tune LLMs; Labs The future of collective knowledge sharing; About the company command idiv operand. In this case, it'll take the sign bit of AL (which happens to be 1) and copy it into every bit of AH. Non-whitespace character, I tried the code in the question (I used NASM so I replaced the writestring and writedec functions with my own), and got the expected output of 4 ((2013 % 10) + 1). However the DIV-Instruction only supports 64/64 Bit divisions. You use it if (as is usual) the value you want to divide is 32-bit to In this video, you will learn how to use the DIV and IDIV instructions in x86 This video is part of my free Foundations of Assembly Programming with nasm course: httpmore. 2. I wanted to do a simple hybrid code using 16-bit assembly, masm. – Johan. Just didn't quite get there. ; You should be using cdq (double to quad word) to sign extend EAX into EDX:EAX instead of cwd (word to double word) to sign extend AX into DX:AX. Or maybe they really do want weird results with negative inputs for some strange reason. How can I multiply or divide two constants in Assembly? imul/mul only set OF and CF, the rest of the flags are undefined (see here or check manual from Intel from which the information was copied). There are other optional instructions that you need to take care of that fast_idiv. should retain content across function calls) in the x86 ABI. Signed divide EDX:EAX by r/m32, with result stored in EAX ← Quotient, EDX ← Remainder. I then want to idiv that 64-bit result by n3. Do simple calculations using the add, sub, mul, and div instructions. Originally (8086), there was just cbw (ax = In this video, you will learn how to use the DIV and IDIV instructions in x86This video is part of my free Foundations of Assembly Programming with nasm cour If you want to deal with numbers larger than 2 32-1, you'll need to do multiple-precision arithmetic. However, many OSs will show the message "floating point exception"; POSIX defines SIGFPE as covering any arithmetic exception. Using intel x86 how do I get the decimal places of a division? Basically I want it to output to the hundredth place like: 12. This instruction is used to divide unsigned integers. Here is my current code: mov AX, Dividend cwd idiv Divisor outputW AX ;Outputs Quotient (whole number) outputW DX ;Outputs Remainder If you just divide by 2 the solution is easy. 0. Examples The assembly instructions don't follow wishes or logic, i. Inside the CPU, the negative "-2" and the positive "4294967294" are transformed to the same value: 0xFFFFFFFE. :) Much appreciated. A quick look in the documentation shows two possibilities for division involving 64-bit numbers:. div bl divides ax by bl and stores the quotient in al, and the remainder in ah. (Unlike with some cases of zero-extension with zero latency (mov / movzx elimination) , there's no downside to sign-extending within the same register instead of to a different register. To check if a number is negative either compare it to zero or inspect the most significant bit (it's set if the number is negative). Commented Nov 8, 2013 at 7:45. The quotient result of the division is stored into EAX, while the remainder is placed in EDX. If AX is positive then DX will get 0, and if AX is negative then DX will get -1. avg = avg + (-1). 10. Otherwise I'll just put in an answer. Failure to do so will result in incorrect results, or a division i got into truble in assembly x86 assignment. It's going to be integer division though. If the source is 16-bit, it is multiplied by the word in AX and the 32-bit result is stored in DX:AX. I was wondering if there are any advantages of using cdq or cwd, when operating on smaller values. xxvcicuxzzagvlyuxswrzmbjtltwtljdwcbrdnexmrszqaobul