This commit is contained in:
Irmen de Jong 2019-07-09 08:42:38 +02:00
parent 5b9cc9592f
commit e8caf6d319
3 changed files with 37 additions and 9 deletions

View File

@ -1 +1 @@
1.9-dev
1.9

View File

@ -361,8 +361,11 @@ You can also create loops by using the ``goto`` statement, but this should usual
Loop variables that are declared inline are scoped in the loop body so they're not accessible at all after the loop finishes.
Conditional Execution (IF)
--------------------------
Conditional Execution
---------------------
if statements
^^^^^^^^^^^^^
Conditional execution means that the flow of execution changes based on certiain conditions,
rather than having fixed gotos or subroutine calls::
@ -413,11 +416,15 @@ So ``if_cc goto target`` will directly translate into the single CPU instruction
Maybe in the future this will be a separate nested scope, but for now, that is
only possible when defining a subroutine.
When - statement (jumptable)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
when statement (jumptable)
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. attention::
TODO: docs for this this must still be written
TODO: docs for this this must still be written.
TODO: the code generator for this is not yet working.
Use a ``when`` statement if you have a set of choices that each should result in a certain
action. It's more readable (and results in faster code) than using a lot of if / else statements.
Assignments

View File

@ -610,7 +610,28 @@ The XX corresponds to one of the eigth branching instructions so the possibiliti
``if_cs``, ``if_cc``, ``if_eq``, ``if_ne``, ``if_pl``, ``if_mi``, ``if_vs`` and ``if_vc``.
It can also be one of the four aliases that are easier to read: ``if_z``, ``if_nz``, ``if_pos`` and ``if_neg``.
**When - statement (jumptable)**
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
when statement (jumptable)
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. attention::
TODO: docs for this this must still be written
TODO: docs for this this must still be written.
TODO: the code generator for this is not yet working.
The condition value can only be an integer datatype.
The choice values must be constant integer values.
code example::
when 4+A+Y {
10 -> {
c64scr.print("ten")
}
5 -> c64scr.print("five")
30 -> c64scr.print("thirty")
99 -> c64scr.print("nn")
55 -> {
; will be optimized away
}
else -> {
c64scr.print("!??!\n")
}
}