• Please review our updated Terms and Rules here

32-Bit arithmetic, using 16-Bit Instructions

MMoeller

Experienced Member
Joined
Aug 19, 2011
Messages
70
Hi,

does someone knowns some assembly source which does 32-Bit Integer Arithmetic using only 16-Bit Instructions.
I thought about the Operations Add, Sub, Mul and Div.

I already searched using Google, but didn't found anything !!!!

With regards,
Martin
 
The built-in multiply instructions handle 32 bit quantities even on an 8088 or 8086. The ADD and SUB instructions (and the variations) can be used to generate 32 bit results as well.

Find an x86 instruction set book and read it. Save the forum for the harder questions.
 
> The built-in multiply instructions handle 32 bit quantities even on an 8088 or 8086.
The MUL instruction allows 16-bit quantities as factors and NOT 32-bit ones (only the result is 32-bit, stored in DX:AX) on pre-386 processors.
The DIV instruction allows 32-bit quantities as dividend/divisor, but only returns 16-bit quotients, and not 32-bit ons on pre-386 processors.

> The ADD and SUB instructions (and the variations) can be used to generate 32 bit results as well.
I know that these instructions can be used to generate 32-bit results as well, if not i hadn't been answered

> Find an x86 instruction set book and read it
hmm.. 'kay

> Save the forum for the harder questions
This question is worth it's answer, as well as every other question, since this is an programming thread for everyone, with his own skills
If this question is not so hard as you state, why don't you have an answer ???
 
Your search may have caused you to miss Randy Hyde's Art of Assembly Programming at http://homepage.mac.com/randyhyde/webster.cs.ucr.edu/www.artofasm.com/index.html or the specific math section at http://homepage.mac.com/randyhyde/w....artofasm.com/DOS/ch06/CH06-2.html#HEADING2-1

That is probably the best free easy explanation of Intel assembly. Much clearer than the Intel manuals and less likely to have major mistakes than my dyslexia would cause.

beat me to it. that book is awesome.
 
There is a ton of books and literature (and even web sites) about doing extended precision arithmetic that goes back a long, long way. Add, subtract and multiply for extended arithmetic (any precision) basically follow the pencil-and-paper method. (i.e. for addition and subtraction, one propagates carry/borrow); since you have a multiply instruction on the 8086, you can use multiple ones, together with addition, to form results of any desired precision. There are several approaches to division (e.g. restoring, non-restoring, reciprocal approximation, etc.).

If you didn't want to derive the code yourself, there is plenty of open-source code out there to show you how.
 
> The built-in multiply instructions handle 32 bit quantities even on an 8088 or 8086.
The MUL instruction allows 16-bit quantities as factors and NOT 32-bit ones (only the result is 32-bit, stored in DX:AX) on pre-386 processors.
The DIV instruction allows 32-bit quantities as dividend/divisor, but only returns 16-bit quotients, and not 32-bit ons on pre-386 processors.

> The ADD and SUB instructions (and the variations) can be used to generate 32 bit results as well.
I know that these instructions can be used to generate 32-bit results as well, if not i hadn't been answered

Yes - the MUL instruction will take 16 bit operands and generate a 32 bit result, but not 32 bit operands. And reading the architecture told you that, which is a great start.

> Find an x86 instruction set book and read it
hmm.. 'kay

> Save the forum for the harder questions
This question is worth it's answer, as well as every other question, since this is an programming thread for everyone, with his own skills
If this question is not so hard as you state, why don't you have an answer ???


It's not my/our job to provide answers if you won't take the first steps!
 
Back
Top