Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arch/zx48k/optimizer/asm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from .patterns import RE_OUTC, RE_INDIR16
from .helpers import single_registers
from zxbasm import z80
from libzxbasm import z80

# Dict of patterns to normalized instructions. I.e. 'ld a, 5' -> 'LD A,N'
Z80_PATTERN = {}
Expand Down
2 changes: 1 addition & 1 deletion arch/zx48k/optimizer/memcell.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .. import backend
from .asm import Asm
from api.utils import flatten_list
from zxbasm import asmlex
from libzxbasm import asmlex


class MemCell(object):
Expand Down
2 changes: 1 addition & 1 deletion arch/zx48k/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from api.errors import InvalidOperatorError
from api.errors import InvalidBuiltinFunctionError
from api.errors import InternalError
from zxbpp import zxbpp
from libzxbpp import zxbpp

from . import backend
from .backend.__float import _float
Expand Down
35 changes: 31 additions & 4 deletions docs/for.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,31 @@

##Description

A **For...Next** loop initializes _iterator_ to _startvalue_, then executes the _sentences_, incrementing _iterator_ by _stepvalue_ until it reaches or exceeds _endvalue_. If _stepvalue_ is not explicitly given it will set to 1.
A **For...Next** loop initializes _iterator_ to _startvalue_, then executes the _sentences_, incrementing _iterator_ by
_stepvalue_ until it reaches or exceeds _endvalue_. If _stepvalue_ is not explicitly given it will set to 1.

##Examples

```
REM Counts from 1 to 10
FOR i = 1 TO 10: PRINT i: NEXT
```

### Counts downwards
```
FOR i = 10 TO 1 STEP -1: PRINT i: NEXT
```

### Loops using odd numbers
```
FOR i = 1 TO 10 STEP 2: PRINT i: NEXT
```

##Differences From Sinclair Basic
* The variable name after the NEXT statement is not required.

* Note that variable types can cause issues with ZX Basic For...Next Loops. If the upper limit of the iterator exceeds the upper limit of the variable type, the loop may not complete.
* Note that variable types can cause issues with ZX Basic For...Next Loops. If the upper limit of the iterator exceeds
the upper limit of the variable type, the loop may not complete.
For example:
```
DIM i as UByte
Expand All @@ -40,9 +53,23 @@ NEXT i

Clearly, since the largest value a byte can hold is 255, it's not possible for i in the above example to exceed 300.
The variable will "wrap around" to 0 and as a result, the loop will not ever terminate.
This can happen in much more subtle ways when STEP is used.
This can happen in much more subtle ways when `STEP` is used.
There has to be "room" within the variable type for the iterator to exceed the terminator when it is being
incremented by "STEP" amounts.
incremented by <step> amounts.

For example, this loop will neved end

```
DIM i as UInteger

FOR i = 65000 TO 65500 STEP 100
...
NEXT i
```

This loop will never end. `UInteger` type allows values in the range `[0..65535]` so apparently it's ok, because
65500 fits in it. However `STEP` is 100, so 65500 + 100 = 65600 which fall out if such range. There will be an
_overflow_ and the variable `i` will take the value 64 and the loop will continue.

##See Also

Expand Down
3 changes: 2 additions & 1 deletion docs/library/screen.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ PRINT AT 0, 0; "The character at 9, 10 is "; c$

* [ CSRLIN ](csrlin_.md)
* [ POS](pos_.md)
* [ AT ](at_.md)
* [ AT ](../at.md)

File renamed without changes.
2 changes: 1 addition & 1 deletion zxbasm/asm.py → libzxbasm/asm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# vim: ts=4:et:sw=4

from zxbasm.z80 import Opcode, Z80SET
from libzxbasm.z80 import Opcode, Z80SET
from api.errors import Error
import re

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion zxbasm/asmparse.py → libzxbasm/asmparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from api.errmsg import warning
from api import global_ as gl
import api.utils
from zxbpp import zxbpp
from libzxbpp import zxbpp
import outfmt

LEXER = asmlex.Lexer()
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion zxbasm/zxbasm.py → libzxbasm/zxbasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import argparse

from . import asmparse
from zxbpp import zxbpp
from libzxbpp import zxbpp

import api.config
from api.config import OPTIONS
Expand Down
2 changes: 1 addition & 1 deletion zxbasm/zxnext.py → libzxbasm/zxnext.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'p_push_imm'
]

from zxbasm import asmparse
from libzxbasm import asmparse


def p_mul_d_e(p):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions zxb/zxb.py → libzxbc/zxb.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from .version import VERSION

from . import zxbparser, zxblex
from zxbpp import zxbpp
from zxbasm import asmparse
from libzxbpp import zxbpp
from libzxbasm import asmparse
import arch.zx48k.backend as backend

from api import global_ as gl
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion zxb/zxbparser.py → libzxbc/zxbparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
# Lexers and parsers, etc
import ply.yacc as yacc
from . import zxblex
from zxbpp import zxbpp
from libzxbpp import zxbpp
from arch.zx48k.backend import REQUIRES
from .zxblex import tokens # analysis:ignore -- Needed for PLY. Do not remove. # noqa

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion zxbpp/zxbasmpplex.py → libzxbpp/zxbasmpplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import sys
from ply import lex
import api.utils
from zxbpp.prepro.output import warning, error
from libzxbpp.prepro.output import warning, error

EOL = '\n'

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion zxbpp/zxbpplex.py → libzxbpp/zxbpplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import sys
from ply import lex
from zxbpp.prepro.output import warning, error
from libzxbpp.prepro.output import warning, error
import api.utils

EOL = '\n'
Expand Down
8 changes: 4 additions & 4 deletions parsetab/tabs.dbm.bak
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'zxbppparse', (0, 69165)
'asmparse', (69632, 253669)
'zxnext_asmparse', (323584, 284580)
'zxbparser', (608256, 708747)
'zxbppparse', (0, 69354)
'asmparse', (69632, 253939)
'zxnext_asmparse', (323584, 284883)
'zxbparser', (608768, 709723)
Binary file modified parsetab/tabs.dbm.dat
Binary file not shown.
8 changes: 4 additions & 4 deletions parsetab/tabs.dbm.dir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'zxbppparse', (0, 69165)
'asmparse', (69632, 253669)
'zxnext_asmparse', (323584, 284580)
'zxbparser', (608256, 708747)
'zxbppparse', (0, 69354)
'asmparse', (69632, 253939)
'zxnext_asmparse', (323584, 284883)
'zxbparser', (608768, 709723)
Loading