# CONUPK

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

Name: | CONUPK
| ||||||

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

Entry point: | $BA8C / 47756 | ||||||

Passed arguments: | |||||||

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

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

Return values: | |||||||

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

X-Register: | stays unchanged | ||||||

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

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

**CONUPK** — sometimes referred to as **MOVMA**^{[1]}, **MEMFC2**^{[2]} or **MEMARG**^{[3]} — transfers a floating-point number from memory to the floating-point register ARG. 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 the compact 5 byte format used to store REAL variables. Both values in RAM and constants in BASIC ROM can be transferred.

## Using[edit | edit source]

**CONUPK** transfers a floating-point number from the memory of the C64 into the floating-point register ARG and prepares it for subsequent use in numeric 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 110/$6E; at the same time, when the mantissa is transferred to addresses 106/$6A to 109/$6D, the leading bit, which is always set, is added there. Finally, in preparation for the numerical routines called up subsequently, CONUPK compares the signs of the floating point registers FAC and ARG, stores the result at address 111/$6F (0: signs are the same, 1: signs are different), and loads the exponent of the number into the accumulator. This last step sets the Zero Flag exactly when FAC is 0. None of the C64's ROM routines use the exponent contained in the accumulator, but the FADDT, FDIVT and FMULTT routines rely on the fact that a set zero flag indicates the number 0 in FAC.

### Runtime behaviour[edit | edit source]

The runtime of **CONUPK** is independent of the value of the transferred number and is usually 85 system cycles. Only in the special case that the floating point number lies on a page limit, the execution time is extended to up to 89 system clocks, as the number is accessed with the help of Indexed zeropage addressing. In the ROM of the C64, this applies to a constant stored at address $E2FF, which is used by the ROM routines COS and SIN.

## Links[edit | edit source]

- Disassembly CONUPK/$BA8C at All About Your 64
- CodeBase 64: Floating Point Math
- C64 BASIC & KERNAL ROM Disassembly by Michael Steil
- C64OS: Floating Point Math from BASIC

### References[edit | edit source]

- ↑ Florian Müller: "C64 für Insider", Markt & Technik, 1988 , S. 462
- ↑ Winfried Kassera/Frank Kassera: "C64 Programmieren in Maschinensprache", Markt & Technik, 1985, S. 301
- ↑ Lothar Englisch: "Das Maschinensprachebuch für Fortgeschrittene zum Commodore 64", Data Becker, 1984 S. 67