-1

How can I convert the floating point "0.5" into a fixed point digit suitable for an assembly code?

Thank you for your answer,

Edit: I am trying to multiply the contents of AX by half, so I wrote IMUL AX,AX,0.5

The assembler refused this and told me "floating-points are not allowed".

All that I want is to divide the contents of AX by two.

Hani
  • 41
  • 4
  • This will depend on what you want to do with it. Assemblers know nothing about fixed point numbers (unless you're trying to use a floating-point extension) so, do what you like. –  Apr 17 '14 at 08:42
  • Floating-point is implemented by specific instructions on the majority of modern processors. Fixed-point has to be implemented by hand using integer instructions. Especially if you are writing in assembly, you should be using floating-point. And your question lacks enough detail to be answerable anyway. – Pascal Cuoq Apr 17 '14 at 08:42
  • Ok, that's a lot different now. Do you want to interpret `AX` as signed or as unsigned? – harold Apr 17 '14 at 08:49
  • I would like to know both the signed and unsigned. – Hani Apr 17 '14 at 08:50

1 Answers1

0

Signed:

cwd
sub ax, dx
sar ax, 1

Unsigned:

shr ax, 1
harold
  • 61,398
  • 6
  • 86
  • 164