From b2ecf16234d2221db73fd7ea3691f91f66997012 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Wed, 9 Jan 2019 22:28:04 +0100 Subject: [PATCH] fixed some array length loop issues --- compiler/prog8lib/prog8lib.p8 | 16 ++++++++++------ docs/source/programming.rst | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/compiler/prog8lib/prog8lib.p8 b/compiler/prog8lib/prog8lib.p8 index 6c2390499..ae4886373 100644 --- a/compiler/prog8lib/prog8lib.p8 +++ b/compiler/prog8lib/prog8lib.p8 @@ -364,7 +364,7 @@ lesseq_ub .proc lda c64.ESTACK_LO+2,x cmp c64.ESTACK_LO+1,x bcc equal_b._equal_b_true - beq equal_b._equal_b_true ; @todo optimize by flipping comparison? + beq equal_b._equal_b_true bcs equal_b._equal_b_false .pend @@ -405,7 +405,7 @@ greater_ub .proc lda c64.ESTACK_LO+2,x cmp c64.ESTACK_LO+1,x beq equal_b._equal_b_false - bcs equal_b._equal_b_true ; @todo optimize by flipping comparison? + bcs equal_b._equal_b_true bcc equal_b._equal_b_false .pend @@ -699,7 +699,8 @@ _greater lda (c64.SCRATCH_ZPWORD1),y dey _lesseq dey dey - bpl _loop ; @todo doesn't work for arrays where y will be >127. FIX OTHER LOOPS TOO! + cpy #254 + bne _loop lda _result_maxuw sta c64.ESTACK_LO,x lda _result_maxuw+1 @@ -736,7 +737,8 @@ _loop dey _lesseq dey dey - bpl _loop + cpy #254 + bne _loop lda _result_maxw sta c64.ESTACK_LO,x lda _result_maxw+1 @@ -896,7 +898,8 @@ _less lda (c64.SCRATCH_ZPWORD1),y dey _gtequ dey dey - bpl _loop + cpy #254 + bne _loop lda _result_minuw sta c64.ESTACK_LO,x lda _result_minuw+1 @@ -933,7 +936,8 @@ _loop dey _gtequ dey dey - bpl _loop + cpy #254 + bne _loop lda _result_minw sta c64.ESTACK_LO,x lda _result_minw+1 diff --git a/docs/source/programming.rst b/docs/source/programming.rst index 7ae33fd50..9e456f1f2 100644 --- a/docs/source/programming.rst +++ b/docs/source/programming.rst @@ -206,7 +206,7 @@ Array types are also supported. They can be made of bytes, words and floats:: .. note:: Right now, the array should be small enough to be indexable by a single byte index. This means byte arrays should be <= 256 elements, word arrays <= 128 elements, and float - arrays <= 51 elements. This limit may or may not be lifted in a future version. + arrays <= 51 elements. You can split an array initializer list over several lines if you want.