assembly
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: assembly

  1. #1
    Junior Member
    Join Date
    Feb 2005
    Posts
    14

    assembly

    is this the right place to ask questions on assembly???

  2. #2
    Banned
    Join Date
    Jun 2003
    Posts
    1,302
    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.

  3. #3
    Banned
    Join Date
    Aug 2001
    Location
    Yes
    Posts
    4,429
    Actually, this is the right place to ask

  4. #4
    Junior Member
    Join Date
    Feb 2005
    Posts
    14
    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

  5. #5
    Senior Member
    Join Date
    Mar 2004
    Posts
    557
    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/double-precision 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://cache-www.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, 1908-70)

  6. #6
    Junior Member
    Join Date
    Feb 2005
    Posts
    14
    thank you for the links.

    what if the code has to be written on a 8088 processor which has only has 16-bit 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.

  7. #7
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,403
    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.

  8. #8
    Junior Member
    Join Date
    Feb 2005
    Posts
    14
    sir dice,

    what if it's a multiply or division operation?

  9. #9
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,403
    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.

  10. #10
    Junior Member
    Join Date
    Feb 2005
    Posts
    14
    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
  •  

 Security News

     Patches

       Security Trends

         How-To

           Buying Guides