UMBC CMSC 313

 


Floating Point Arithmetic Operations

The FPU is a stack machine. Arithmetic is performed by pushing the two operands onto the stack, and then exectuing an arithmetic opcode, which in effect pops the two top items, does the operation with the the two values and then pushs the result back on the stack. The slots in the stack are numbered ST0, ST1, ST2, ..., ST7.
fadd ST0 + ST1
fsub ST0 - ST1
fsubr ST1 - ST0
fmul ST0 X ST1
fdiv ST0 / ST1
fdivr ST1 / ST0
These can have the letter p appended.

Some FPU Miscellaneous Arithmetic

  fabs            ; Absolute value     Set ST0 to |ST0|
  fchs            ; Chage sign of ST0  Set ST0 to -ST0
  fsqrt           ; Square root.       Set ST0 to sqrt(ST0)

©2004, Gary L. Burt