MOVMF

From C64-Wiki
Jump to navigationJump to search

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

Name: MOVMF
Description: Round floating point register FAC and store in memory
Entry point: $BBD4 / 48084
Passed arguments:
X-Register: Target address of the floating point value (Low-Byte)
Y register: Target address of the floating point value (High-Byte)
Return values:
Accumulator: Exponent of FAC
X-Register: unchanged
Y register: 0
zero flag: set if FAC = 0, otherwise deleted

MOVMF — sometimes also as MOVFM[1] or FACMEM[2] — rounds the contents of the floating point register FAC and then stores it in memory. The memory address of this floating point number is passed in the X register (low byte) and in the Y register (high byte). The number is written in compact 5-byte format, as used to store REAL variables.

Usage[edit | edit source]

MOVMF 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 The routine MOVMF is only entered at address $BBD7 / 48087. In very rare cases, after rounding, the contents of FAC can no longer be represented as a floating point number on the C64, in this case MOVMF triggers an ?OVERFLOW ERROR.

Runtime behavior[edit | edit source]

The running time of MOVMF consists of the computing time for rounding FAC and for storing FAC in memory.

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. However, if FAC is rounded up before copying, this will take between 47 and 99 system cycles.

Storing FAC in memory always takes 81 system clocks, regardless of the contents of FAC.

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

Weblinks[edit | edit source]

Sources[edit | edit source]