Search code examples
assemblyfixed-point

How to write 0.5 in assembly language code?


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.


Solution

  • Signed:

    cwd
    sub ax, dx
    sar ax, 1
    

    Unsigned:

    shr ax, 1