hth313 / Calypsi-tool-chains

Overview of the Calypsi tool chain and open source support packages
16 stars 0 forks source link

AS65816 not assembling, but not showing any errors either #10

Closed ProxyPlayerHD closed 1 year ago

ProxyPlayerHD commented 1 year ago

Floating Point performance in C is pretty bad, so i wanted to port my Fixed Point library from cc65 to calypsi. but some functions are written in assembly to keep code size down, so i had to rewrite some stuff.

problem is, when trying to assemble my "fixed to int" function... the assembler just doesn't want to do it for no visible reason (even with the -v option). here's the command i use: AS65816 -v --code-model large --data-model large -l Output\fxtoint.lst -o Temp\fxtoint.o fxtoint.s (on a side note, i'm still a bit confused why the assembler throws a hissy fit if source files don't end on .s or .asm as unlike with C there is no standard for assembly file extensions)

anyways, here the code i'm trying to assemble:

; ---------------------------------------------------------------------------
; fxtoint.s
; ---------------------------------------------------------------------------
;
; Convert from Fixed Point to Integer
;

    .rtmodel version,"1"
    .rtmodel codeModel,"large"
    .rtmodel dataModel,"large"
    .rtmodel core,"*"

; ---------------------------------------------------------------------------
; int16_t fxtoint(fix16_t value);

; Low Word: A
; High Word:    X

    .section farcode, text
    .public fxtoint
fxtoint:
    CPX ##0             ; Check if the Number is Negative
    BMI 1$              ; If it is, do the Negative Rounding, otherwise continue
    ASL A               ; Put the MSB of the Fractional part into the Carry
    TXA                 ; Get the Integer part into A
    ADC ##0             ; And Add the Carry to it (ie if the fractional part was 0.5 or larger this adds 1 to the Integer part)
    RTL

1$: EOR ##0x8000        ; Invert the MSB of the Fractional Part
    ASL A               ; Then shift it into the Carry
    TXA                 ; Get the Integer part into A
    SBC ##0             ; Subtract the Carry from it (basically if the fractional part was 0.5 or larger this subtracts 1 from the Integer part)
    RTL

am i missing something obvious? why won't the assembler tell me what's wrong? :(

ProxyPlayerHD commented 1 year ago

oh i'm stupid... well i had my reasons to be stupid! i thought -v was "verbose" like in most other compilers/assemblers but in this case it just prints the version.... oof. so yea disregard this issue (though i'd still like the assembler to ignore file extensions, and have you thought about built-in fixed point functionality as a more performant alternative to floats?)

hth313 commented 1 year ago

The version command is intended to print the version and stop, but I should not have -v to mean version, it should only be the long command --version. If will fix that.

The extension matter I will look into at some point, it is on the list, I just have not got there yet.