; Generated by Calypsi ISO C compiler for 65816

            .rtmodel version,"1"
            .rtmodel codeModel,"large"
            .rtmodel dataModel,"small"
            .rtmodel core,"65816"
            .rtmodel huge,"0"
            .rtmodel target,"none-specified"
            .extern _Dp
            .extern _Mul16
            .extern _Vfp
;  unsigned long sumOfSquares(unsigned short n) {
            .section farcode,text
            .public sumOfSquares
sumOfSquares:
            phy
            phy
            sta     1,s
;      unsigned long total = 0;
            stz     dp:.tiny _Dp
            stz     dp:.tiny (_Dp+2)
;      for (unsigned short i = 1; i <= n; i++) total += (unsigned long)i * i;
            lda     ##1
            sta     3,s
`?L5`:      lda     1,s
            cmp     3,s
            bcs     `?L4`
;      return total;
            ldx     dp:.tiny (_Dp+2)
            lda     dp:.tiny _Dp
;  }
            ply
            ply
            rtl
`?L4`:      lda     3,s
            tax
            jsl     long:_Mul16
            clc
            adc     dp:.tiny _Dp
            pha
            txa
            adc     dp:.tiny (_Dp+2)
            tax
            pla
            stx     dp:.tiny (_Dp+2)
            sta     dp:.tiny _Dp
            lda     3,s
            inc     a
            sta     3,s
            bra     `?L5`

