Skip to content

FOR LOOP repeating #178

Description

@em00k

I find this for loop repeats, only happens if to is set to 255

for x = 0 to 255 
	print at 0,0;x
	pause 1
next x 
pause 0

Activity

  1. added a commit that references this issue on Nov 13, 2018
  2. em00k commented on Jan 19, 2021

    @em00k
    Author

    Sorry ignore my last post on this.

  3. self-assigned this
    on Nov 3, 2024
  4. boriel commented on Nov 3, 2024

    @boriel
    Collaborator

    I've been thinking of an alternate (and efficient) way to implement this, by using Carry Flag (at least for 8 bits variables).
    Maybe in the near future I could come up with a better solution.
    In the mean time, the loop above can be rewritten as:

    Dim x as UByte
    Let x = 0
    Do
      Print At 0, 0; x
      Pause 1
      Let x = x + 1
    Loop Until x = 0  : REM yes, overflow
  5. boriel commented on Nov 28, 2024

    @boriel
    Collaborator

    Alternatively, the initial FOR loop will cause the Z80's Carry Flag to be set. Maybe I can take advantage of this and detect the FOR loop ending!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

featureFeature request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions