irmen / prog8

high level programming language and compiler targeting 6502 machines such as the C-64 and CommanderX16
https://prog8.readthedocs.io/
Other
152 stars 18 forks source link

Add 24-bit integer-to-float routine and floating-point jiffy clock reader #150

Closed markjreed closed 2 months ago

markjreed commented 2 months ago

This adds two new routines to the floats library on the c64 and cx16 targets:

irmen commented 2 months ago

Hmm, observing 2 different weird behaviors

main {
    sub start() {
        cbm.SETTIM(0,0,0)
        float xx = floats.time()
        floats.print(xx)
        txt.nl()
        floats.print(floats.time())
        txt.nl()
    }
}

prints:

8388608 <- expected 0, is there something in the FAC that MOVMF doesn't like when it copies it to xx 0000000 <- this immediately uses FAC1, but why does the print float routine output this as 0000000 instead of 0

markjreed commented 2 months ago

Hmm, observing 2 different weird behaviors

Yeah, that last simplification we discussed in Discord broke it. Restored the version that shifts everything to the correct exponent and it seems to work now.