library-math32

Guides editing and rebuilding the z88dk math32 IEEE single-float library across multiple Z80-family CPU targets.

1.1k|206|Updated Mar 16, 2016
One-click install
npx skills add https://github.com/z88dk/z88dk --skill library-math32-z88dk
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: library-math32
Source: https://github.com/z88dk/z88dk/tree/main/.agents/skills/library-math32
Command: npx skills add https://github.com/z88dk/z88dk --skill library-math32-z88dk

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Maintaining the z88dk math32 IEEE single-precision float library is error-prone because it spans many CPU variants (z80, z80n, z180, ez80_z80, r2ka, kc160, 8085, 8080, vm1, gbz80), each with its own assembly cores, rounding policies, and build lists. This Skill encodes the layout, rounding rules, divide/inverse algorithm policy, and force-rebuild procedures so edits stay consistent and every affected library product gets rebuilt. ## Core Features & Use Cases - Multi-CPU layout map: Documents which directory (asm/z80/, asm/8085/, asm/8080/, asm/vm1/, asm/gbz80/, c/*) holds which cores and which newlibfiles_*.lst produces each math32*.lib product. - Rounding and algorithm policy: Records IEEE RNE for mul/sqr/div/sqrt, jam-sticky for add/sub, restoring divide versus Newton-Raphson inverse, and signed-Inf overflow rules so changes do not silently alter numerics. - Force rebuild procedures: Provides exact z88dk-z80asm commands to rebuild one object and relink every product that shares a source file, plus verification via z88dk-z80nm. - Use Case: When fixing a bug in the shared asm/z80/d32_fsadd.asm, use this Skill to identify all six affected library products, rebuild each one, install into lib/clibs/, and verify symbols before re-running the math test suite. ## Quick Start Ask the assistant to rebuild the math32 8085 library after editing f32_fsadd.asm and verify the new object is present in lib/clibs/math32_8085.lib.

Frequently Asked Questions about library-math32

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I rebuild the z88dk math32 library after editing a shared assembly file?

Delete the stale object and target .lib, reassemble with z88dk-z80asm using the matching newlibfiles list and -m CPU flag, then relink with the math32 link list and copy the result into lib/clibs. Repeat for every CPU product that lists the shared file, such as all Z80-family products sharing asm/z80/d32_fsadd.asm.

How do I link the math32 float library for 8085 or gbz80 targets?

Link with the single --math32 flag, which resolves to -lmath32@{ZCC_LIBCPU} such as math32_8085 or math32_gbz80. There are no separate per-CPU flags like --math32_8085; the CPU-specific library is selected automatically.

What rounding policy does math32 use for add versus multiply?

Multiply, square, divide, polynomial, and sqrt packing use IEEE round-to-nearest-even on the residual below the kept mantissa. Add and subtract use Digi jam-sticky, OR-ing 1 into the mantissa LSB when alignment or overflow bits are lost, with no RNE residual in the pack stage.

Should I use m32_invf or 1.0/x for a reciprocal in math32 C code?

Write 1.0/x, which uses the restoring divide core, rather than m32_invf, since Newton-Raphson inverse is slower than divide for a plain reciprocal. Keep m32_invsqrtf for inverse square root because it remains the fastest 1/sqrt path.

Why does sccz80 with newlib --math32 produce wrong numerics or zero hits on math32 symbols?

The newlib proto math.h must remap plain names like sin to sin_fastcall under __MATH_MATH32, matching the classic header. Without the remaps, sccz80 emits fastcall calls into stack-bridge objects that ignore DEHL, causing wrong numerics and misleading benchmark timings.

Can I build the eZ80 Z80-mode math32 library from the plain z80 list?

No. math32_ez80_z80.lib must be built from newlibfiles_ez80_z80.lst, which selects the Z180 mlt-based mantissa helpers gated on __CPU_EZ80_Z80__. The plain-Z80 helpers assemble empty under -mez80_z80, so the library would be incomplete.