# MOVFM

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

Name: | MOVFM
| ||||||

Description: | Fill floating point register FAC with number from memory | ||||||

Entry point: | $BBA2 / 48034 | ||||||

Passed arguments: | |||||||

Accumulator: | Address of the floating point value (Low-Byte) | ||||||

Y register: | Address of the floating point value (High-Byte) | ||||||

Return values: | |||||||

Accumulator: | Exponent of FAC | ||||||

X-Register: | remains unchanged | ||||||

Y register: | 0 | ||||||

zero flag: | set if FAC = 0, otherwise deleted |

**MOVFM** — sometimes also as **MOVMF**^{[1]} or **MEMFAC**^{[2]}^{[3]} — transfers a floating point number from memory to the floating point register FAC. The memory address of this floating point number is passed in the accumulator (low byte) and in the Y register (high byte). The number must be in compact 5-byte format, as used to store REAL variables. Both values in RAM and constants in BASIC-ROM can be transferred.

## Usage[edit | edit source]

**MOVFM** transfers a floating point number from the C64's memory to the floating point register FAC and prepares it for subsequent use in numerical routines. For this purpose, the most significant Byte of the mantissa, which contains the sign of the number in the most significant bit, is copied separately to address 102/$66, in parallel when the Mantissa to the addresses 98/$62 to 101/$65 the always set leading bit is added there. In preparation for subsequently called numerical routines, MOVFM finally deletes the rounding byte at address 112/$70. None of the C64 ROM routines use the exponent returned in the accumulator, although the FPWR routine relies on a set zero flag indicating the number 0 in FAC after calling MOVFM.

### Runtime behavior[edit | edit source]

The running time of **MOVFM** is independent of the value of the number transmitted and is usually 76 system cycles. Only in the special case that the floating point number is on a Page-Limit, the execution time is extended to up to 80 system cycles, since the number is accessed using the Y-postindexed zeropage addressing is accessed.

## Weblinks[edit | edit source]

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