-4

alghoritm

code

I write implementation Shell sort in assemble. My problem is at end this code. I have number in EAX and I want do this. EAX=EAX/2,2

Vojta Matras
  • 69
  • 1
  • 8
  • It looks like your post is mostly code; please add some more details. :/ – Vojta Matras May 19 '16 at 20:13
  • I know, but when i want add my code. Error message thrown "It looks like your post is mostly code; please add some more details" – Vojta Matras May 19 '16 at 20:19
  • i add my code to link I want divide in label else – Vojta Matras May 19 '16 at 20:21
  • 2
    Does it need to be exactly `2.2`? If `2.2069` is close enough you could achieve that with `imul eax, eax, 29` / `shr eax, 6` – Michael May 19 '16 at 20:23
  • _"It looks like your post is mostly code; please add some more details"_ That's a strong hint that you shouldn't post questions that consist only of a code dump with a title, and that you should spend some time writing a better question. – Michael May 19 '16 at 20:23

1 Answers1

1

I didn't read your code since you can't be bothered to even put it in your question.


An integer approximation is probably your best bet, see Michael's comment. Otherwise do it with SSE:

cvtsi2ss   xmm0, eax
divss      xmm0, [a_float_constant]
cvtss2si   eax, xmm0

Use cvttss2si if you want truncation instead of round-to-nearest.


Or with x87:

push eax, fld 2.2 from a constant, fdivr [rsp]. st(0) = (double)eax/2.2. Don't forget to fix the stack when you're done.

See the tag wiki for links to the insn set manual.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847