# MOVFA

*Note: This article describes the MOVFA routine for transferring floating point values in BASIC-ROM.*

Name: | MOVFA
| ||||||

Description: | Round floating point register FAC and copy to floating point register ARG. | ||||||

Entry point: | $BC0C / 48140 | ||||||

Passed arguments: | |||||||

Return values: | |||||||

Accumulator: | Exponent of FAC and ARG | ||||||

X-Register: | 0 | ||||||

Y register: | unchanged | ||||||

zero flag: | set | ||||||

Negative flag: | deleted |

**MOVFA**^{[1]} — sometimes also as **FACARG**^{[2]} or **FAC1/2**^{[3]} — rounds the contents of the floating point register FAC and then copies it to the floating point register ARG.

## Usage[edit | edit source]

**MOVFA** first rounds the contents of the floating point register FAC, i.e. increases the mantissa of FAC by 1 if the most significant bit of the rounding byte was set to address 112/$70 by a previous arithmetic operation. If this is not desired or is unnecessary - for example because the content of FAC was previously read from memory using MOVFM and the rounding byte therefore has the value *0* anyway - rounding can be omitted by entering MOVFA routine at address $BC0F / 48143. In very rare cases, after rounding, the contents of FAC can no longer be represented as a floating point number on the C64, in which case MOVFA triggers an ` ?OVERFLOW ERROR`.

MOVFA is called by numerous ROM routines. The exponent of FAC returned in the accumulator is reused by some routines, for example by MUL10.

### Runtime behavior[edit | edit source]

The running time of MOVFA consists of the computing time for rounding FAC and for copying from FAC to ARG.

If *FAC = 0* or if the most significant bit of the rounding byte at address 112/$70 is cleared, rounding does not change the value of FAC. In these cases, calling the ROM routine for rounding only requires 18 or 25 system cycles. If, on the other hand, FAC has to be rounded up before copying, the effort required for this is between 47 and 99 system cycles.

Copying from FAC to ARG always requires 94 cycles, regardless of the content of FAC.

On the Commodore 64, one system clock corresponds to around one microsecond (μs).

## Weblinks[edit | edit source]

- Disassembly of MOVFA/$BC0C on All About Your 64
- CodeBase 64: Floating Point Math
- C64 BASIC & KERNAL ROM Disassembly by Michael Steil
- C64OS: Floating Point Math from BASIC