
February 22nd, 2005, 02:50 PM
#1
Junior Member
assembly
is this the right place to ask questions on assembly???

February 22nd, 2005, 03:16 PM
#2
Not really, but there are people here that can help you.
If you have a question ask it, and someone will get back to you.

February 22nd, 2005, 03:40 PM
#3
Actually, this is the right place to ask

February 22nd, 2005, 03:47 PM
#4
Junior Member
ok.my first question is regarding assembly arimethic.i understand that when u want do add a or subtract two data's that are more than a word long,u would have to process it one word at a time right?so what about multiplying and dividing data that is more than a word long???
thanks

February 23rd, 2005, 05:36 AM
#5
Hi
Unfortunately, it is not such a simple task to perform what you want,
at least as much as I know.
I suggest you look up the SSE2 (or start with SSE[1])instruction set.
I have some experience with those, but I mainly dealt with the optimisation
of single/doubleprecision floating point arithmetics  by parallelising rather
than having quadword operations[2]. The ops you are interested in are
paddq, psubq and pmuludq (division has to be replaced by inversion (~approximated)
and multiplication. Be careful, you might run into give carry/borrow problems.
Cheers.
[1] http://www.intel.com/software/produc...d/download.htm
[2] http://cachewww.intel.com/cd/00/00/...ng_started.pdf
If the only tool you have is a hammer, you tend to see every problem as a nail.
(Abraham Maslow, Psychologist, 190870)

February 23rd, 2005, 09:51 AM
#6
Junior Member
thank you for the links.
what if the code has to be written on a 8088 processor which has only has 16bit registers?i just need to know the method to accomplish this task.but a source code would be much appreciated.
i'm just asking this question for academic purposes only and i am just stumped at this point.
thanks.

February 23rd, 2005, 10:07 AM
#7
Make use of the carry flag.
I don't know much about i386 assembly but I used to do a lot of 6510 and 68000 assembly.
The idea should be the same...
If you add 2 numbers together the carry flag will be set when it doesn't 'fit' anymore.
Add the next 2 numbers and add the carry flag. etc... Just like you would do a 'regular' addition on paper.
If you add 9 and 2 i.e. you're basicly using a carry because 11 doesn't 'fit' anymore into 1 digit (on a 10based number system).
So you add 9 and 2... which is 1 and a carry. The next digit is 0 + 0 + carry(1). That makes 11.
Same idea works for bigger numbers..
Oliver's Law:
Experience is something you don't get until just after you need it.

February 23rd, 2005, 10:47 AM
#8
Junior Member
sir dice,
what if it's a multiply or division operation?

February 23rd, 2005, 01:18 PM
#9
How do you multiply? Using MUL or shifting bits?
Shifting bits is probably easier and perhaps faster (MUL uses a lot of cycles and may not be available RISC i.e.).
I hope you know that shifting 1 bit to the left is the same as multiplying by 2?
I'll use a 4 bit example but the same principle works for 8, 16, 32 and 64 bits.
4 bit: 2 x 4
0100 (4) shift 1 bit to the left makes 1000 (8).
4 bit: 2 x 9
1001 (9) shift 1 bit to the left makes 0010 and the carry bit gets set. Shift that carry bit into the next 4 bits.. and you get 0001 0010 (18)
What if you need to multiply by 3?
4 bit: 3 x 4 = (2 x 4) + 4
shift 1 bit like above and add 4... 1000 + 0100 = 1100 (12)
4 bit: 3 x 9 = (2 x 9) + 9
same as above for 2x9 and add 9.. 0001 0010 + 0000 1001 = 0001 1011 (27)
Does that make sense?
Edit: Just in... You could also use a repeated addition (loop). 6x4 = 4+4+4+4+4+4
Oliver's Law:
Experience is something you don't get until just after you need it.

February 23rd, 2005, 04:10 PM
#10
Junior Member
sir dice ,
thank you.that was briliant.
"3 x 4 = (2 x 4) + 4"
"3 x 9 = (2 x 9) + 9"
how did you come to that conclusion?
so i guess that for division we just use repeated subtration right or shift to the right,correct?
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

