Math in asm... and limits...
From: Simon (spamtrap_at_crayne.org)
Date: 02/22/05
- Next message: Charles A. Crayne: "Re: Advice Please: Assembly Language Programming Book"
- Previous message: Pedro Ferreira: "Convert from BGRA to RGBA using MMX"
- Next in thread: Matt: "Re: Math in asm... and limits..."
- Reply: Matt: "Re: Math in asm... and limits..."
- Reply: Chris Williams: "Re: Math in asm... and limits..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 22 Feb 2005 19:41:53 +0000 (UTC)
Hi,
I am trying to refresh my memory when it comes to assembly math...please
bear with me it's been 9 years since I last looked at it.
If I have 3 numbers A, B C and I want to add them.
I would do something like...
MOV ax, A ; ax = A
ADD B, ax ; ax = A+B or ax+=B
ADD C, ax ; ax = A+ B + C or ax+=C
MOV ax, C ; c = A+B+C...
would the above be right? especially the last line.
SUB is for subtractions, (what about limits?...see below)
multiplications are
MOV ax, A
mul B; ax*=B
mul C; ax*=C
MOV C, ax ; C= ax
Again, what about overflows to DX, how do I handle them to get the 'correct'
value of C within it's own limits.
So my questions are...
Where would I define the data types of A, B and C?
Do the command, MOV ax, A, make ax the same type as A?
What are the types? do float, double even exist in assembly?
What are the limitations, (surely ax as a maximum value).
What about the overflow?
And how would you do A+B+C to ensure that the overflows are handled
properly?
Last but not least I am working on a Windows/Intel machine, does it make a
difference?
How can I test my code above?
Many thanks in advance for any help/pointers.
Simon
- Next message: Charles A. Crayne: "Re: Advice Please: Assembly Language Programming Book"
- Previous message: Pedro Ferreira: "Convert from BGRA to RGBA using MMX"
- Next in thread: Matt: "Re: Math in asm... and limits..."
- Reply: Matt: "Re: Math in asm... and limits..."
- Reply: Chris Williams: "Re: Math in asm... and limits..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|