mirror of
https://github.com/irmen/prog8.git
synced 2024-11-20 03:32:05 +00:00
fix for loop pre-check
This commit is contained in:
parent
05d152746f
commit
f37f062cdc
@ -64,16 +64,20 @@ internal class ForLoopsAsmGen(private val program: PtProgram,
|
||||
+ bpl $endLabel""")
|
||||
else
|
||||
asmgen.out("""
|
||||
clc
|
||||
sec
|
||||
sbc $varname
|
||||
bvc +
|
||||
eor #${'$'}80
|
||||
+ bmi $endLabel""")
|
||||
} else {
|
||||
if(stepsize<0)
|
||||
asmgen.out(" cmp $varname | bcs $endLabel")
|
||||
asmgen.out("""
|
||||
cmp $varname
|
||||
beq +
|
||||
bcs $endLabel
|
||||
+""")
|
||||
else
|
||||
asmgen.out(" cmp $varname | bcc $endLabel | beq $endLabel")
|
||||
asmgen.out(" cmp $varname | bcc $endLabel")
|
||||
asmgen.out(" sta $modifiedLabel+1")
|
||||
}
|
||||
asmgen.out(loopLabel)
|
||||
@ -106,16 +110,20 @@ $modifiedLabel cmp #0 ; modified
|
||||
+ bpl $endLabel""")
|
||||
else
|
||||
asmgen.out("""
|
||||
clc
|
||||
sec
|
||||
sbc $varname
|
||||
bvc +
|
||||
eor #${'$'}80
|
||||
+ bmi $endLabel""")
|
||||
} else {
|
||||
if(stepsize<0)
|
||||
asmgen.out(" cmp $varname | bcs $endLabel")
|
||||
asmgen.out("""
|
||||
cmp $varname
|
||||
beq +
|
||||
bcs $endLabel
|
||||
+""")
|
||||
else
|
||||
asmgen.out(" cmp $varname | bcc $endLabel | beq $endLabel")
|
||||
asmgen.out(" cmp $varname | bcc $endLabel")
|
||||
asmgen.out(" sta $modifiedLabel+1")
|
||||
}
|
||||
asmgen.out(loopLabel)
|
||||
@ -291,14 +299,17 @@ $endLabel""")
|
||||
if(iterableDt==DataType.ARRAY_W) {
|
||||
if(stepsize<0)
|
||||
asmgen.out("""
|
||||
sta P8ZP_SCRATCH_REG
|
||||
cmp $fromVar
|
||||
tya
|
||||
sbc $fromVar+1
|
||||
sta P8ZP_SCRATCH_W2 ; to
|
||||
sty P8ZP_SCRATCH_W2+1 ; to
|
||||
lda $fromVar
|
||||
cmp P8ZP_SCRATCH_W2
|
||||
lda $fromVar+1
|
||||
sbc P8ZP_SCRATCH_W2+1
|
||||
bvc +
|
||||
eor #${'$'}80
|
||||
+ bpl $endLabel
|
||||
lda P8ZP_SCRATCH_REG""")
|
||||
+ bmi $endLabel
|
||||
lda P8ZP_SCRATCH_W2
|
||||
ldy P8ZP_SCRATCH_W2+1""")
|
||||
else
|
||||
asmgen.out("""
|
||||
sta P8ZP_SCRATCH_REG
|
||||
|
@ -202,6 +202,7 @@ Look in the `syntax-files <https://github.com/irmen/prog8/tree/master/syntax-fil
|
||||
targetsystem.rst
|
||||
technical.rst
|
||||
portingguide.rst
|
||||
upgrading8.rst
|
||||
todo.rst
|
||||
|
||||
|
||||
|
54
docs/source/upgrading8.rst
Normal file
54
docs/source/upgrading8.rst
Normal file
@ -0,0 +1,54 @@
|
||||
Upgrading from version 8
|
||||
========================
|
||||
|
||||
How to upgrade older programs written for Prog8 version 8 or earlier to version 9.
|
||||
|
||||
cx16diskio -> diskio
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The ``cx16diskio`` module is gone, just use ``diskio``. The drivenumber is no longer a parameter on all routines.
|
||||
|
||||
* replace all imports and references to ``cx16diskio`` with just ``diskio``
|
||||
* remove all drive number arguments from the calls. If you're not using drive 8, set the correct drive
|
||||
with a call to ``diskio.set_drive()``. Read the active drive from ``diskio.drivenumber``.
|
||||
* replace load calls that use a ram bank argument by setting the ram bank first using ``cx16.rambank()``
|
||||
and then call the load routine normally.
|
||||
|
||||
|
||||
@Pc now ``bool``
|
||||
^^^^^^^^^^^^^^^^
|
||||
Parameters and return values passed via the carry status flag (@Pc) now need to be declared as ``bool``.
|
||||
(Previously also ``ubyte`` was allowed but as the value is just a single bit, this wasn't really correct)
|
||||
|
||||
|
||||
``cbm`` contains kernal calls
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Instead of ``c64``, the CBM compatible kernal calls such as CHROUT, and variables, are now
|
||||
located in the ``cbm`` module. You don't have to import this module as it is part of the syslib.
|
||||
|
||||
* replace all references such as ``c64.CHROUT`` with the ``cbm`` module instead to fix those undefined symbol errors.
|
||||
|
||||
|
||||
some routines moved to ``sys``
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Several routines have been moved to the ``sys`` module rather than being in ``c64`` or ``cx16`` for instance.
|
||||
An example is ``set_irq()``. If you fixed the previous item above, and still get undefined symbol errors,
|
||||
the routine is likely now located in the ``sys`` module so simplychange its prefix to ``sys.``
|
||||
|
||||
|
||||
for loop range checking to avoid wrap-around looping
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
Modify any for loops that depend on a 'wrap-around' loop where the from value lies
|
||||
outside of the the loop range (for example: a loop from $fe to $02 which used to loop through $fe, $ff, $00, $01 and $02).
|
||||
For loops now do a check at the start and skip the whole loop if the start value is already outside of the range.
|
||||
This is the normal behavior of most other programming languages.
|
||||
|
||||
|
||||
For 9.0 major changes
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
- DONE: added min() max() builtin functions
|
||||
- DONE: rename sqrt16() to just sqrt(), make it accept multiple numeric types. Renamed floats.sqrt() to floats.sqrtf() but you can just use sqrt()
|
||||
- DONE: abs() now supports multiple datatypes including float. No need to use floats.fabs() anymore.
|
||||
- DONE: divmod() now supports multiple datatypes. divmodw() has been removed.
|
||||
|
||||
|
@ -1,16 +1,19 @@
|
||||
%import textio
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
|
||||
sub start() {
|
||||
ubyte @shared foo = derp(99)
|
||||
}
|
||||
word vfrom = $1000
|
||||
word vto = $1000
|
||||
|
||||
asmsub derp(ubyte xx @Y) -> ubyte @ A {
|
||||
%asm {{
|
||||
rts
|
||||
|
||||
}}
|
||||
word xx
|
||||
for xx in vfrom to vto step -1 {
|
||||
txt.print_w(xx)
|
||||
txt.spc()
|
||||
}
|
||||
skip:
|
||||
txt.nl()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user