mirror of
https://github.com/irmen/prog8.git
synced 2024-09-07 03:54:27 +00:00
repaired min(f) max(f) fixes #13
This commit is contained in:
parent
3e7e44acfe
commit
fc47d3feb8
@ -893,46 +893,44 @@ _cmp_mod cpy #255 ; modified
|
|||||||
.pend
|
.pend
|
||||||
|
|
||||||
func_max_f .proc
|
func_max_f .proc
|
||||||
lda #<_min_float
|
|
||||||
ldy #>_min_float
|
|
||||||
jsr c64flt.MOVFM ; fac1=min(float)
|
|
||||||
lda #255
|
lda #255
|
||||||
sta _cmp_mod+1 ; compare using 255 so we keep larger values
|
sta _minmax_cmp+1
|
||||||
_minmax_entry jsr pop_array_and_lengthmin1Y
|
lda #<_largest_neg_float
|
||||||
|
ldy #>_largest_neg_float
|
||||||
|
_minmax_entry jsr MOVFM
|
||||||
|
jsr prog8_lib.pop_array_and_lengthmin1Y
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx c64.SCRATCH_ZPREGX
|
||||||
- sty c64.SCRATCH_ZPREG
|
- sty c64.SCRATCH_ZPREG
|
||||||
lda c64.SCRATCH_ZPWORD1
|
lda c64.SCRATCH_ZPWORD1
|
||||||
ldy c64.SCRATCH_ZPWORD1+1
|
ldy c64.SCRATCH_ZPWORD1+1
|
||||||
jsr c64flt.FCOMP
|
jsr FCOMP
|
||||||
_cmp_mod cmp #255 ; will be modified
|
_minmax_cmp cmp #255 ; modified
|
||||||
bne +
|
bne +
|
||||||
; fac1 is smaller/larger, so store the new value instead
|
|
||||||
lda c64.SCRATCH_ZPWORD1
|
lda c64.SCRATCH_ZPWORD1
|
||||||
ldy c64.SCRATCH_ZPWORD1+1
|
ldy c64.SCRATCH_ZPWORD1+1
|
||||||
jsr c64flt.MOVFM
|
jsr MOVFM
|
||||||
ldy c64.SCRATCH_ZPREG
|
+ lda c64.SCRATCH_ZPWORD1
|
||||||
dey
|
|
||||||
cmp #255
|
|
||||||
beq +
|
|
||||||
lda c64.SCRATCH_ZPWORD1
|
|
||||||
clc
|
clc
|
||||||
adc #5
|
adc #5
|
||||||
sta c64.SCRATCH_ZPWORD1
|
sta c64.SCRATCH_ZPWORD1
|
||||||
bcc -
|
bcc +
|
||||||
inc c64.SCRATCH_ZPWORD1+1
|
inc c64.SCRATCH_ZPWORD1+1
|
||||||
|
+ ldy c64.SCRATCH_ZPREG
|
||||||
|
dey
|
||||||
bne -
|
bne -
|
||||||
+ jmp push_fac1_as_result
|
jmp push_fac1_as_result
|
||||||
_min_float .byte 255,255,255,255,255 ; -1.7014118345e+38
|
rts
|
||||||
|
_largest_neg_float .byte 255,255,255,255,255 ; largest negative float -1.7014118345e+38
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
func_min_f .proc
|
func_min_f .proc
|
||||||
lda #<_max_float
|
|
||||||
ldy #>_max_float
|
|
||||||
jsr c64flt.MOVFM ; fac1=max(float)
|
|
||||||
lda #1
|
lda #1
|
||||||
sta func_max_f._cmp_mod+1 ; compare using 1 so we keep smaller values
|
sta func_max_f._minmax_cmp+1
|
||||||
|
lda #<_largest_pos_float
|
||||||
|
ldy #>_largest_pos_float
|
||||||
jmp func_max_f._minmax_entry
|
jmp func_max_f._minmax_entry
|
||||||
_max_float .byte 255,127,255,255,255 ; 1.7014118345e+38
|
_largest_pos_float .byte 255,127,255,255,255 ; largest positive float
|
||||||
|
rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
func_sum_f .proc
|
func_sum_f .proc
|
||||||
|
Loading…
Reference in New Issue
Block a user